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

C#

 
GeneralRe: multithreading Pin
Dave Kreskowiak9-Feb-05 6:25
mveDave Kreskowiak9-Feb-05 6:25 
QuestionHow to get Paragraph leading? Pin
sachinkalse8-Feb-05 18:23
sachinkalse8-Feb-05 18:23 
AnswerRe: How to get Paragraph leading? Pin
sachinkalse9-Feb-05 13:29
sachinkalse9-Feb-05 13:29 
GeneralI'm having trouble adding records to Access Pin
Bill Prada8-Feb-05 17:09
Bill Prada8-Feb-05 17:09 
GeneralRe: I'm having trouble adding records to Access Pin
Luis Alonso Ramos8-Feb-05 19:00
Luis Alonso Ramos8-Feb-05 19:00 
GeneralRe: I'm having trouble adding records to Access Pin
bprada9-Feb-05 4:22
bprada9-Feb-05 4:22 
GeneralRe: I'm having trouble adding records to Access Pin
Luis Alonso Ramos9-Feb-05 5:10
Luis Alonso Ramos9-Feb-05 5:10 
GeneralRe: I'm having trouble adding records to Access Pin
Luis Alonso Ramos9-Feb-05 5:21
Luis Alonso Ramos9-Feb-05 5:21 
bprada wrote:
cmd.CommandText = "INSERT INTO 3 VALUES ca[0], ca[1], ca[2]";

And also, the ca[n] are variables, so you should put them out of the string literal, and since their data type is char, enclose them in single quotes in the SQL statement:
cmd.CommandText = "INSERT INTO 3 VALUES ('" + ca[0] + "','" + ca[1] + "','" + ca[2] + "')";
But I don't recommend string concatenation as it is any easy way to allow SQL-injecton attacks. So I'd use the Parameters property of the OleDbCommand as I mentioned in my first post:
OleDbCommand cmd = new OleDbCommand("INSERT INTO 3 VALUES (?, ?, ?);", conn);
cmd.Parameters.Add("@param1", ca[0]);  // If you are using Sql* classes (for
cmd.Parameters.Add("@param1", ca[1]);  // SQL server or MSDE) parameters are
cmd.Parameters.Add("@param1", ca[2]);  // named, check the docs
cmd.ExecuteNonQuery();
And by the way, in your case 6, you also need to change your SQL statement so you take your variables our of the string literal (or better yet, use parametized queries.)

-- LuisR



Luis Alonso Ramos
Intelectix - Chihuahua, Mexico

Not much here: My CP Blog!

Generali got stuckup with my first C# program Pin
nagarajuepuri8-Feb-05 15:39
nagarajuepuri8-Feb-05 15:39 
GeneralRe: i got stuckup with my first C# program Pin
Daniel Turini8-Feb-05 15:58
Daniel Turini8-Feb-05 15:58 
GeneralRe: i got stuckup with my first C# program Pin
nagarajuepuri8-Feb-05 16:09
nagarajuepuri8-Feb-05 16:09 
GeneralRe: i got stuckup with my first C# program Pin
S. Senthil Kumar8-Feb-05 18:13
S. Senthil Kumar8-Feb-05 18:13 
GeneralRe: i got stuckup with my first C# program Pin
Mr.Cooper9-Feb-05 1:18
Mr.Cooper9-Feb-05 1:18 
GeneralRe: i got stuckup with my first C# program Pin
nagarajuepuri9-Feb-05 6:09
nagarajuepuri9-Feb-05 6:09 
GeneralRe: i got stuckup with my first C# program Pin
Dave Kreskowiak9-Feb-05 6:22
mveDave Kreskowiak9-Feb-05 6:22 
GeneralDon't display form icon Pin
.gonad8-Feb-05 15:32
.gonad8-Feb-05 15:32 
GeneralRe: Don't display form icon Pin
Mr.Cooper9-Feb-05 1:20
Mr.Cooper9-Feb-05 1:20 
GeneralRe: Don't display form icon Pin
.gonad10-Feb-05 14:35
.gonad10-Feb-05 14:35 
GeneralCard Selection Screen Pin
Bob Bonser8-Feb-05 15:29
Bob Bonser8-Feb-05 15:29 
QuestionHow do I find out if a file is signed or not? Pin
ethanwa8-Feb-05 14:54
ethanwa8-Feb-05 14:54 
Questionfast way to find the index of the first letter in a richTextBox? Pin
ektoras8-Feb-05 13:53
ektoras8-Feb-05 13:53 
AnswerRe: fast way to find the first letter in a richTextBox? Pin
Christian Graus8-Feb-05 14:02
protectorChristian Graus8-Feb-05 14:02 
GeneralRe: fast way to find the first letter in a richTextBox? Pin
ektoras8-Feb-05 14:17
ektoras8-Feb-05 14:17 
GeneralRe: fast way to find the first letter in a richTextBox? Pin
mav.northwind8-Feb-05 20:20
mav.northwind8-Feb-05 20:20 
GeneralRe: fast way to find the first letter in a richTextBox? Pin
ektoras8-Feb-05 23:10
ektoras8-Feb-05 23:10 

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.