i have a Access DB table there is only one row allowed so if no row exist it shouls create one else it should just update it. What should i put in the if statement?
Code:
if ()
{
int i = 1;
string UpdateStr = "Insert into qx_Company " +
"(AST__ID, AST__NAME, AST__STREET, AST__TOWN, AST__CITY, AST__TEL, AST__FAX, AST__MAIL, AST__SITE, AST__POST )" +
"values(" +i.ToString()+ ",'"+ txtComp_Name.Text +"','"+ txtComp_Street.Text + "','"+ txtComp_Town.Text +"','"+ txtComp_City.Text +"','"+ txtComp_Tel.Text +"','"+ txtComp_Fax.Text + "','"+ txtComp_Email.Text +"','"+ txtComp_Website.Text +"',"+ txtComp_Box.Text +")";
}else{
string UpdateStr = "UPDATE qx_Company SET AST__NAME = '" + txtComp_Name.Text +"', " +
" AST__STREET = '" + txtComp_Street.Text + "', " +
" AST__TOWN = '" + txtComp_Town.Text + "', " +
" AST__CITY = '" + txtComp_City.Text + "', " +
" AST__TEL = '" + txtComp_Tel.Text + "', " +
" AST__FAX = '" + txtComp_Fax.Text + "', " +
" AST__MAIL = '" + txtComp_Email.Text + "', " +
" AST__SITE = '" + txtComp_Website.Text +"', " +
" AST__POST = '" + txtComp_Box.Text + "', " +
}
Comment