0

i have this insert code that is refusing to work it is giving me error 26: something to do with the network or connection.
i am using sql express 2005 and vb.net 2008 any help will be greatly appreciated

]
Dim MyConnection As SqlConnection

        Dim sqlstring As String = "INSERT INTO items_table (item)  VALUES ('" & Me.txtItem.Text & "')"
        'Dim data_base As String = " C:\Documents and Settings\admin\Desktop\OCSWalkthrough\OCSWalkthrough\App_Data\Testing_DB.sdf"
        Dim data_base As String = " C:\vb2008\Visual Studio 2008\Projects\morevariables\morevariables\App_Data\test_db.mdf;Integrated Security=True;User Instance=True"

        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()
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by __avd
0

Wrong connection string

MyConnection = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFileName=" & data_base)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.