In response to your comment
Quote:
if i enter username value into a textbox displayed in fil form application
write a query to insert data into table by using where clause like the following code
command.CommandText = "insert into BasicDtl_tbl([Nationality],[Post]) values ('" + Nattxt.Text + "','" + apldposttxt.Text + "') WHERE UserName =usertxt.Text ";
is this the right way of writing a query
- you are very close. You don't need the join to table UserReg, as you have worked out. I would advise you to always use
Parameterized Queries[
^] when using data entered by a user. For example
string sql = "insert into BasicDtl_tbl([Nationality],[Post]) values (?,?) WHERE UserName =?";
using (OleDbCommand command = new OleDbCommand(SqlString, conn))
{
command.CommandType = CommandType.Text;
command.Parameters.AddWithValue("Nationality", Nattxt.Text);
command.Parameters.AddWithValue("Post", apldposttxt.Text);
command.Parameters.AddWithValue("Post", usertxt.Text);
command.ExecuteNonQuery();
}
Notice all I've done is replace the textboxes in
your sql with question marks (?) and added the lines to create the parameters