hi all..urgent help needed plzzzz
Well i have this data to enter into the database using vb.net and sqlserver...i did the coding and it was all working fine until yesterday..i installed in on clients system but now...its taking someother data into it..the ward field is taking a defualt value not the value which is choosen by the user...rest all r working fine except ward field...what should i do..can soebody explain me y did it happen all of a sudden when it was working fine till yesterday...let me explain the code
Private Sub Submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox2.Text = "" Or TextBox3.Text = "" Or ComboBox4.Text = "" Or ComboBox3.Text = "" Or ComboBox5.Text = "" Or TextBox1.Text = "" Or ComboBox1.Text = "" Or ComboBox6.Text = "" Then
MessageBox.Show("Enter all Values")
Else
con = New SqlConnection("Server=;uid=sa;pwd=;Database=")
con.Open()
Dim param As New SqlParameter()
param.ParameterName = "@PhoneNumber"
param.Value = TextBox1.Text + TextBox2.Text
myCommand = New SqlCommand("Insert into Telecheck(DateCheck,Entryname,Hospital,Ward,PhoneNumber,StaffName,StatusOfStaff,StatusOfPhone)values(getdate(),@Entryname,@Hospital,@Ward,@PhoneNumber,@StaffName,@StatusOfStaff,@StatusOfPhone)", con)
myCommand.Parameters.Add(New SqlClient.SqlParameter("@Hospital", ComboBox1.SelectedItem.ToString()))
myCommand.Parameters.Add(New SqlClient.SqlParameter("@Ward", ComboBox3.SelectedValue.ToString()))
myCommand.Parameters.Add(param)
'myCommand.Parameters.Add(New SqlClient.SqlParameter("@PhoneNumber", TextBox2.Text))
myCommand.Parameters.Add(New SqlClient.SqlParameter("@StaffName", TextBox3.Text))
myCommand.Parameters.Add(New SqlClient.SqlParameter("@Entryname", ComboBox6.Text))
myCommand.Parameters.Add(New SqlClient.SqlParameter("@StatusOfStaff", ComboBox4.SelectedItem.ToString()))
myCommand.Parameters.Add(New SqlClient.SqlParameter("@StatusOfPhone", ComboBox2.SelectedItem.ToString()))
ra = myCommand.ExecuteNonQuery()
MessageBox.Show("Record entered")
con.Close()
ComboBox1.Text = ""
TextBox1.Text = ""
ComboBox2.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
ComboBox6.Text = ""
ComboBox5.Text = ""
ComboBox3.Text = ""
ComboBox4.Text = ""
End If
End Sub
the above is the wy i used to enter ward details into the database but now it is not entering the choosen value of combo box its taking some other defualt value and entering into the database...i dont know why it happened all of a sudden...what could be the problem...now i am taking the values into this combobox like this
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
TextBox1.Text = ""
ComboBox5.Text = ""
Dim cn As New SqlConnection("Server=;uid=sa;pwd=;Database=")
cn.Open()
Dim cmd As SqlCommand = New SqlCommand("select Ward from Wardplans where Hospital='" & ComboBox1.SelectedItem.ToString() & "'", cn)
Dim ad As SqlDataAdapter = New SqlDataAdapter(cmd)
Dim t As New DataTable
ad.Fill(t)
ComboBox3.BeginUpdate()
ComboBox3.DataSource = t
ComboBox3.DisplayMember = "Ward"
ComboBox3.ValueMember = "Ward"
ComboBox3.EndUpdate()
cn.Close()
End Sub