0

hi
this is my coding i run no error message but the data is not inserted in the table. i need help what is error in this program

Dim MyConnection As New SqlClient.SqlConnection
Dim MyCommand As New SqlCommand
Dim connstring As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Documentcreation.mdf;Integrated Security=True;User Instance=True"
Dim insstr As String = ""
Dim disp As Integer
MyConnection.ConnectionString = connstring
MyCommand.Connection = MyConnection
MyConnection.Open()
Dim rs As Date = Today
If MyConnection.State = ConnectionState.Open Then
MyCommand = New SqlCommand("insert into prak values (2,'" & txtdevelopercode.Text & "')", MyConnection)
disp = MyCommand.ExecuteNonQuery()
End If
MsgBox("Succesfully saved…")
MyConnection.Close()

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by MeSampath
0

Hi,

The code works fine for me. What is the error that you are getting while inserting the record? Is that any error related to SQL Client?
Please post the error that you are facing and also do not forget to use code-tags while posting codes.

Thank you

Edited by mike_2000_17: Fixed formatting

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.