Click here to Skip to main content
15,888,521 members
Home / Discussions / C#
   

C#

 
GeneralRe: Mem Usage Pin
Dave Kreskowiak7-Apr-04 1:35
mveDave Kreskowiak7-Apr-04 1:35 
GeneralRe: Mem Usage Pin
DougW487-Apr-04 1:43
DougW487-Apr-04 1:43 
GeneralRe: Mem Usage Pin
Heath Stewart7-Apr-04 6:13
protectorHeath Stewart7-Apr-04 6:13 
GeneralUserControl and interface implementation Pin
Corneliu Tusnea6-Apr-04 22:28
Corneliu Tusnea6-Apr-04 22:28 
GeneralRe: UserControl and interface implementation Pin
Heath Stewart7-Apr-04 5:46
protectorHeath Stewart7-Apr-04 5:46 
GeneralRe: UserControl and interface implementation Pin
Corneliu Tusnea7-Apr-04 13:26
Corneliu Tusnea7-Apr-04 13:26 
Generaluneable to update an Access database Pin
michael.wikstrom6-Apr-04 22:14
michael.wikstrom6-Apr-04 22:14 
GeneralRe: uneable to update an Access database Pin
Heath Stewart7-Apr-04 4:49
protectorHeath Stewart7-Apr-04 4:49 
The way you're doing it is not optimal and often leads to problems because certain characters - like quotes - are not escaped properly. See the documentation for the OleDbParameter class and use a paramterized query like so:
OleDbCommand cmd = myConnection.CreateCommand();
cmd.CommandText = "UPDATE userinfo SET Password=? WHERE " +
  "Name=? AND Password=?";
cmd.Parameters.Add("NewPassword", OleDbType.VarWChar, 40).Value = newPassword;
cmd.Parameters.Add("Name", OleDbType.VarWChar, 40).Value = user.Name;
cmd.Parameters.Add("OlePassword", OleDbType.VarWChar, 40).Value = oldPassword;
int i = cmd.ExecuteNonQuery();
Console.WriteLine("{0} record(s) modified", i);
The OLE DB provider for ADO.NET does not use named parameters, and instead uses positional parameters using the question mark, so you must add your parameters in the same order. The example aboves assumes you declare your fields as Text using 40 characters as the length. This is just an example, though, so read the documentation for the OleDbParameter for more information.

 

Microsoft MVP, Visual C#
My Articles
GeneralAutomailer Pin
sreejith ss nair6-Apr-04 19:54
sreejith ss nair6-Apr-04 19:54 
GeneralRe: Automailer Pin
Dave Kreskowiak7-Apr-04 1:43
mveDave Kreskowiak7-Apr-04 1:43 
QuestionHow to get the IP of SqlServer? Pin
Member 6449646-Apr-04 19:53
Member 6449646-Apr-04 19:53 
AnswerRe: How to get the IP of SqlServer? Pin
Colin Angus Mackay7-Apr-04 0:12
Colin Angus Mackay7-Apr-04 0:12 
GeneralRe: How to get the IP of SqlServer? Pin
Member 6449647-Apr-04 15:58
Member 6449647-Apr-04 15:58 
GeneralRe: How to get the IP of SqlServer? Pin
Dave Kreskowiak8-Apr-04 3:06
mveDave Kreskowiak8-Apr-04 3:06 
AnswerRe: How to get the IP of SqlServer? Pin
Heath Stewart7-Apr-04 4:42
protectorHeath Stewart7-Apr-04 4:42 
GeneralRe: How to get the IP of SqlServer? Pin
Member 6449647-Apr-04 16:00
Member 6449647-Apr-04 16:00 
GeneralDatagrid Record Numbering Pin
sreejith ss nair6-Apr-04 19:49
sreejith ss nair6-Apr-04 19:49 
GeneralRe: Datagrid Record Numbering Pin
Heath Stewart7-Apr-04 3:52
protectorHeath Stewart7-Apr-04 3:52 
QuestionMicrosoft.DirectX and image ??? Pin
student66696-Apr-04 19:39
student66696-Apr-04 19:39 
AnswerRe: Microsoft.DirectX and image ??? Pin
CWIZO6-Apr-04 20:52
CWIZO6-Apr-04 20:52 
GeneralRe: Microsoft.DirectX and image ??? Pin
Heath Stewart7-Apr-04 3:47
protectorHeath Stewart7-Apr-04 3:47 
GeneralRe: Date Pin
Christian Graus6-Apr-04 19:35
protectorChristian Graus6-Apr-04 19:35 
QuestionArrayList.........how to access??? Pin
Paolo Ponzano6-Apr-04 18:00
Paolo Ponzano6-Apr-04 18:00 
AnswerRe: ArrayList.........how to access??? Pin
Christian Graus6-Apr-04 19:03
protectorChristian Graus6-Apr-04 19:03 
AnswerRe: ArrayList.........how to access??? Pin
sreejith ss nair6-Apr-04 20:15
sreejith ss nair6-Apr-04 20:15 

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.