I have faced a problem with the dataset when inserting record into DB.I have a table address in which phno (AllowNulls=False,Defaultvalue='0') and mbno(AllowNulls=True,Defaultvalue='0') .While inserting record into database through dataset when I didn't supply any input to the both columns phno is taking default value('0') and mbno is taking "Null".I suppose both has to take default value when there is no input.
I dont know why this is happening.I have written code like this
SqlConnection con = new SqlConnection(connStr);
DataSet ds = new DataSet();
DataRow dr;
SqlCommand cmd = new SqlCommand("select * from address",con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
SqlCommandBuilder cmdBuilder;
da.FillSchema (ds,SchemaType.Source );
da.Fill(ds, "address");
dr = ds.Tables["address"].NewRow();
dr["sname"] = "tomy";
dr["fname"] = "peter";
ds.Tables["address"].Rows.Add(dr);
cmdBuilder = new SqlCommandBuilder(da);
da.Update(ds, "address");