Click here to Skip to main content
15,892,199 members
Home / Discussions / C#
   

C#

 
GeneralUpdate Large DataTable Pin
Wayne Phipps5-Jan-05 9:17
Wayne Phipps5-Jan-05 9:17 
GeneralRe: Update Large DataTable Pin
Bill Dean5-Jan-05 9:46
Bill Dean5-Jan-05 9:46 
GeneralRe: Update Large DataTable Pin
Wayne Phipps5-Jan-05 10:01
Wayne Phipps5-Jan-05 10:01 
GeneralRe: Update Large DataTable Pin
Robert Rohde5-Jan-05 19:07
Robert Rohde5-Jan-05 19:07 
GeneralMultithreading... Pin
Peter Molnar5-Jan-05 8:13
Peter Molnar5-Jan-05 8:13 
GeneralRe: Multithreading... Pin
leppie5-Jan-05 11:51
leppie5-Jan-05 11:51 
GeneralRe: Multithreading... Pin
Charlie Williams5-Jan-05 11:52
Charlie Williams5-Jan-05 11:52 
Questionhow to insert a record to Access database ? Pin
DuyNguyen5-Jan-05 7:57
DuyNguyen5-Jan-05 7:57 
I tried to insert a record to database(in user register operation) using Access 2003 database and an exception appears("this operation must use updateable queries.").But when i use the same code with SQL2000 Database,every thing is OK.
Anyone can explain for me,and how to insert a record to Access database ? thanks.

the full code:
/////////////////////////////////////////////////
bool result = false;
//OLEDB
OleDbConnection dbConnection = new System.Data.OleDb.OleDbConnection(CfgKeyOleConnString+CfgKeyOleDatabase);

string strSQL = "INSERT INTO Users (UserName,Name,UserPassword,Email,RoleID) VALUES (@UserName,@Name,@UserPassword,@Email,@RoleID)";
OleDbCommand dbComm = new OleDbCommand(strSQL,dbConnection);

dbComm.Parameters.Add(new OleDbParameter ("@UserName", OleDbType.VarChar, 50));
dbComm.Parameters["@UserName"].Value = userName;
dbComm.Parameters.Add(new OleDbParameter ("@Name", OleDbType.VarChar, 50));
dbComm.Parameters["@Name"].Value = displayName;
dbComm.Parameters.Add(new OleDbParameter ("@UserPassword", OleDbType.VarChar, 50));
dbComm.Parameters["@UserPassword"].Value = userPassword;
dbComm.Parameters.Add(new OleDbParameter ("@Email", OleDbType.VarChar, 50));
dbComm.Parameters["@Email"].Value = userEmail;
dbComm.Parameters.Add(new OleDbParameter ("@RoleID", OleDbType.Numeric , 8));
dbComm.Parameters["@RoleID"].Value = Convert.ToInt32(Role);

try
{
dbConnection.Open();
dbComm.ExecuteNonQuery();
result = true;
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
result = false;
}
finally
{
if (dbConnection.State==ConnectionState.Open)
dbConnection.Close();
}
return result;


...NLD...
AnswerRe: how to insert a record to Access database ? Pin
Charlie Williams5-Jan-05 11:46
Charlie Williams5-Jan-05 11:46 
GeneralFun with SetSocketOption Pin
tantiboh5-Jan-05 7:53
tantiboh5-Jan-05 7:53 
GeneralRe: Fun with SetSocketOption Pin
leppie5-Jan-05 12:00
leppie5-Jan-05 12:00 
GeneralGlad I'm stumping people Pin
tantiboh5-Jan-05 18:50
tantiboh5-Jan-05 18:50 
Questionhorizontal GUI in C#. Is it possible? Pin
Daniel Tomasini5-Jan-05 5:41
Daniel Tomasini5-Jan-05 5:41 
AnswerRe: horizontal GUI in C#. Is it possible? Pin
Judah Gabriel Himango5-Jan-05 6:25
sponsorJudah Gabriel Himango5-Jan-05 6:25 
GeneralRe: horizontal GUI in C#. Is it possible? Pin
Daniel Tomasini5-Jan-05 6:47
Daniel Tomasini5-Jan-05 6:47 
QuestionHow does one display a check box in a datagrid column Pin
ChillGamer5-Jan-05 4:10
ChillGamer5-Jan-05 4:10 
AnswerRe: How does one display a check box in a datagrid column Pin
Richard Parsons5-Jan-05 4:33
Richard Parsons5-Jan-05 4:33 
AnswerRe: How does one display a check box in a datagrid column Pin
ChillGamer5-Jan-05 4:37
ChillGamer5-Jan-05 4:37 
GeneralRe: How does one display a check box in a datagrid column Pin
Richard Parsons5-Jan-05 5:16
Richard Parsons5-Jan-05 5:16 
GeneralClash of time format using MSAccess Pin
Anonymous5-Jan-05 3:49
Anonymous5-Jan-05 3:49 
GeneralRe: Clash of time format using MSAccess Pin
Skynyrd6-Jan-05 3:24
Skynyrd6-Jan-05 3:24 
Generalsetting include paths and executable paths Pin
elena123455-Jan-05 3:30
elena123455-Jan-05 3:30 
GeneralReading the Contact Database from my application on a pocket pc Pin
Alphaconsult5-Jan-05 3:16
Alphaconsult5-Jan-05 3:16 
GeneralDataGrid scrolling Pin
Jonckheere5-Jan-05 2:41
Jonckheere5-Jan-05 2:41 
GeneralPictureBox Exception Pin
sadica5-Jan-05 2:28
sadica5-Jan-05 2:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.