hi,
I'm trying to get daya into a new table via form. two fields in new table will pick up data based on look up tables.
pls guide as to how do i proceed . The code is flashing conversion of Data type error.
To avoid the datatype error, i 've already taken category_id and city_id fields in DB as varchar.
Thanks
protected void btnWinesAvailable_Click(object sender, EventArgs e)
{
conn.Open();
SqlCommand cmd1 = new SqlCommand("Insert into wines_available(name, address, city_id, category_id) values (@name, @address, @cityid, @categoryid)", conn);
string a =("select city_id from city_master where city_name= '" + ddlCityname.SelectedItem + "'");
string b= ("select category_id from category_master where category = '"+ ddlCategoryname.SelectedItem+ "'");
cmd1.Parameters.Add(new SqlParameter("@name", txtOrgName.Text));
cmd1.Parameters.Add(new SqlParameter("@address", txtAddress.Text));
cmd1.Parameters.Add(new SqlParameter("@cityid", SqlDbType.Char,10)).Value = a;
cmd1.Parameters.Add(new SqlParameter("@categoryid", SqlDbType.Char, 10)).Value = b;
cmd1.ExecuteNonQuery();
txtOrgName.Text = "";
txtAddress.Text = "";
//txtCityID1.Text = "";
//txtCategoryID1.Text = "";
conn.Close();
conn.Dispose();
}