Start New Discussion within our Software Development Community

can someone help me with why this code is not inserting into the database

Dim MyConnection As SqlConnection

        Dim sqlstring As String = "INSERT INTO Workers (FName, LName, FullName)  VALUES ('" & Me.txtName.Text & "', '" & Me.txtSurname.Text & "', '" & Me.txtFullName.Text & "')"
        'Dim data_base As String = " C:\Documents and Settings\admin\Desktop\OCSWalkthrough\OCSWalkthrough\App_Data\Testing_DB.sdf"
        Dim data_base As String = " Data Source=NetServer;Initial Catalog=Testing_DB;User ID=xx;Password=xxxxxx"

        MyConnection = New SqlConnection("Data Source=" & data_base)
        Dim concom As SqlCommand = MyConnection.CreateCommand()


        MyConnection.Open()

        Dim cmnd As SqlCommand = New SqlCommand(sqlstring, MyConnection)

        cmnd.ExecuteNonQuery()        ' Execute the command here

        'and then read
        Dim myreader As SqlDataReader

        myreader = cmnd.ExecuteReader

        MyConnection.Close()

I got it

Dim MyConnection As SqlConnection
        Dim sqlstring As String = "INSERT INTO Workers (First_Name, Last_Name, Full_Name)  VALUES ('" & Me.txtName.Text & "', '" & Me.txtLastName.Text & "', '" & Me.txtFullName.Text & "')"
        Dim data_base As String = " Data Source=siv01-win1.wadns.net;Initial Catalog=Testing_DB;User ID=sa;Password=1234"
        MyConnection = New SqlConnection(data_base)
        Dim concom As SqlCommand = MyConnection.CreateCommand()
        MyConnection.Open()
        Dim cmnd As SqlCommand = New SqlCommand(sqlstring, MyConnection)
        cmnd.ExecuteNonQuery()        ' Execute the command here
This question has already been answered. Start a new discussion instead.