ByVal e As System.EventArgs) Handles MyBase.Load
' Put user code to initialize the page here
' Passing the Data Panel to the navigator coz it'll not
' work from design mode properties (bug)
SqlDataNavigator1.ControlToNavigate = Me.SqlDataPanel1
' also passing the connection string from web.config
' becoz passing it from the design mode will not work (bug)
SqlDataPanel1.Connection = New _
SqlConnection(System.Configuration.ConfigurationSettings.AppSettings(_
"ConnStr"))
'and finally passing it to the navigator too.
SqlDataNavigator1.Connection = Me.SqlDataPanel1.Connection
End Sub
'Handling the add record btn
Private Sub DataAddButton1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles DataAddButton1.Click
Dim insertStr As String = "insert into Employees" & _
" (LastName,FirstName,Title,City,Country,HomePhone,Notes) values('"_
+ Me.LastName_Txt.Text + "','" + Me.FirstName_Txt.Text + _
"','" + Me.Title_Txt.Text + "', '" + Me.City_Txt.Text + _
"','" + Me.Cntry_Txt.Text + "','" + Me.HomePhone_Txt.Text + _
"','" + Me.Notes_Txt.Text + "')"
Dim conn As New _
SqlConnection(System.Configuration.ConfigurationSettings.AppSettings(_
"ConnStr"))
Dim cmd As New SqlCommand(insertStr, conn) |