Insert SQL not working

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mabond

    #1

    Insert SQL not working

    Hi

    Can anyone tell me where I have gone wrong with the following code : it runs
    without errors, but does not insert the record in the table!

    Private Sub Button3_Click(B yVal sender As System.Object, ByVal e As
    System.EventArg s) Handles Button3.Click
    Dim myConnection As SqlClient.SqlCo nnection
    Dim myCommand As SqlClient.SqlCo mmand
    Dim insertCMD As String

    myConnection = New SqlConnection _
    ("Data Source=.\SQLEXP RESS;AttachDbFi lename=|DataDir ectory|" _
    + "\Bata_CallInfo .mdf;Integrated Security=True;U ser
    Instance=True")
    myConnection.Op en()
    insertCMD = "Insert into CallLog (AccessCode) values ('18002');"

    myCommand = New SqlCommand(inse rtCMD, myConnection)
    myCommand.Execu teNonQuery()
    myConnection.Cl ose()

    End Sub


    VB.net 2005 Express, SQL Server 2005 Express, Windows XP Professional
    "AccessCode " is a field name of type (VarChar(17))

    Thanks

    Michael Bond
  • mabond

    #2
    RE: Insert SQL not working

    Hi

    ignore this question ...... there is nothing wrong with the code ......

    I did not realise with vb.net 2005 I had to contend with "design time" and
    "run time" copies of the databse .......

    Not to worry, I'm really quite pleased. I've been using these discussions
    groups for 3-4 years and have received much valuable help ..... and this is
    the first time Ive answered a posting (even if it is my own!!!)

    "mabond" wrote:
    Hi
    >
    Can anyone tell me where I have gone wrong with the following code : it runs
    without errors, but does not insert the record in the table!
    >
    Private Sub Button3_Click(B yVal sender As System.Object, ByVal e As
    System.EventArg s) Handles Button3.Click
    Dim myConnection As SqlClient.SqlCo nnection
    Dim myCommand As SqlClient.SqlCo mmand
    Dim insertCMD As String
    >
    myConnection = New SqlConnection _
    ("Data Source=.\SQLEXP RESS;AttachDbFi lename=|DataDir ectory|" _
    + "\Bata_CallInfo .mdf;Integrated Security=True;U ser
    Instance=True")
    myConnection.Op en()
    insertCMD = "Insert into CallLog (AccessCode) values ('18002');"
    >
    myCommand = New SqlCommand(inse rtCMD, myConnection)
    myCommand.Execu teNonQuery()
    myConnection.Cl ose()
    >
    End Sub
    >
    >
    VB.net 2005 Express, SQL Server 2005 Express, Windows XP Professional
    "AccessCode " is a field name of type (VarChar(17))
    >
    Thanks
    >
    Michael Bond

    Comment

    Working...