if textbox is not enabled , a null value must be entered in a database.
i tried this but there is an error " value of type DBnull cannot be converted to string"
Code:If pretTxt.Enabled = False Then pretTxt.Text = DBNull .value
and i am trying to do this so that i can insert something like this.
Code:If pretTxt.Enabled = False Then pretTxt.Text = DBNull .value Dim cmd As New SqlCommand("insert into Marks_master (subject_id, student_id, T_PA_marks, T_ET_marks, P_PA_marks,P_ET_marks) VALUES(@si,@stdid, @tet ,@tpa, @pet, @ppa)", con) cmd.Parameters.AddWithValue("si", subjectLbl.Text) cmd.Parameters.AddWithValue("stdid", studentidTxt.Text) cmd.Parameters.AddWithValue("tet", thetTxt.Text) cmd.Parameters.AddWithValue("tpa", thpaTxt.Text) cmd.Parameters.AddWithValue("pet", pretTxt.Text) cmd.Parameters.AddWithValue("ppa", prpaTxt.Text) Try cmd.ExecuteNonQuery() MessageBox.Show("Record added") Catch ex As Exception MessageBox.Show("Error while adding record") End Try con.Close()
if textbox is not enabled then null value must be inserted in the table.




Reply With Quote