Private Sub InsertDatabase()
Dim rowaffected As Integer
Dim SqlInsert As String
Dim fname As String
Dim mname As String
Dim lname As String
Dim ConnPPC As New System.Data.SqlServerCe.SqlCeConnection("Data Source =" + (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\test.sdf;"))
ConnPPC.Open()
fname = Me.txtfname.Text
mname = Me.txtmname.Text
lname = Me.txtlname.Text
Dim cmd As SqlCeCommand = ConnPPC.CreateCommand
Try
SqlInsert = "INSERT INTO test1(firstname,middlename,lastname) VALUES('" & fname & "','" & mname & "','" & lname & "')"
cmd.CommandText = SqlInsert
cmd.Connection = ConnPPC
rowaffected = cmd.ExecuteNonQuery()
If rowaffected = 1 Then
MsgBox("Client added succefully")
Else
MsgBox("Cannot add new client")
End If
ConnPPC.Close()
Catch ex As Exception
MsgBox("Error :" & ex.ToString)
End Try
End Sub