But Every time I run the codes, it just don't do anything. It only shows the msgbox prompt which I put to indicate confirmation.
I have 2 text boxes and 3 combo boxes. how do I add records into the sql table.
I simply want to add records from the form to the sql database table
emphasis should also be laid on the combo boxes too... what properties should be used when adding records to a database table?
Below are the codes i have used
'If txtAddID.Text = "" Then
' MsgBox("Abeg Complete d Form b4 I break ur head!", MsgBoxStyle.Information)
' Else
' On Error Resume Next
' Dim MyMsg
' Dim con As New SqlConnection("server = REXYSPY\SQLEXPRESS;Initial Catalog=master;Integrated Security=True")
' Dim cmd As New SqlCommand("insert into dbo.tblSchools values ('" + txtAddID.Text + "','" + txtAddInstitution.Text + "','" + cboAddInstituteState.Text + "','" + cboAddInstituteRegion.Text + "','" + cboAddInstituteType.Text + "')")
' cmd.Connection = con
' con.Open()
' cmd.Parameters.AddWithValue("@ID", Me.txtAddID.Text)
' cmd.Parameters.AddWithValue("@Sname", Me.txtAddInstitution.Text)
' cmd.Parameters.AddWithValue("@Sstate", Me.cboAddInstituteState.Text)
' cmd.Parameters.AddWithValue("@Sregion", Me.cboAddInstituteRegion.Text)
' cmd.Parameters.AddWithValue("@Stype", Me.cboAddInstituteType.Text)
' Dim reader As SqlDataReader = Nothing
' cmd.ExecuteNonQuery()
'
' con.Close()
' MyMsg = MsgBox("Your Information don enta. You wan enta again", 4, "Confirmation!")
' If MyMsg = 7 Then
' Me.Close()
' Input.Show()
' End If
' End If

New Topic/Question
Reply



MultiQuote




|