insert into desg values(" & Val(txtsno.Text) & ",'" & Trim(txtdesg.Text) & "'," & Val(txtbasic.Text) & ");

this how i used for inserting data to my access table in vb code.
how to do in c#?

Re: insert query in c# 80 80

"insert into desg values(" & Val(txtsno.Text) & ",'" & Trim(txtdesg.Text) & "'," & Val(txtbasic.Text) & ");" this how i used for inserting data to my access table in vb code.
how to do in c#?

I am unable to understand the motive the query.Give wat you want to do.

Re: insert query in c# 80 80
"INSERT INTO desg VALUES(" + txtsno.Text + ", " + txtdesg.Text +", " + txtbasic.Text + ");";

You dont need to worry about Trim and Val functions here. Trim will happen automatically and Val is irrelevant here

Re: insert query in c# 80 80

You should also stear away from inserting code just like that. Look into adding parameters:

SqlCommand comm = new SqlCommand("INSERT INTO desg VALUES (@txtsno, @txtdesg, @txtbasic)", connection);
comm.Parameters.AddWithValue("@txtsno", txtsno.Text.Trim());
comm.Parameters.AddWithValue("@txtsno", txtdesg.Text.Trim());
comm.Parameters.AddWithValue("@txtsno", txtbasic.Text.Trim());

This prevents SQL Injection.

Re: insert query in c# 80 80

sonakrish how do i insert Radio box value into the access database. for example, S=Small, M=Medium, or L=Large.

Re: insert query in c# 80 80

INSERT INTO user_login (user_Name) VALUES (@user_Name)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.