Name 'ExecuteNonQuery' is not declared error when doing insert

I am trying to insert  data into a new row in a sql database.  I can get this to work in an access database but when I convert everything over to the sql I get the following error

Name 'ExecuteNonQuery' is not declared

Below is the code I am using.
All variables are definced prior to running the insert command.

Thanks for your help

Me.SqlInsertCommand1.CommandText = "INSERT INTO callcenter_outbound_timer(campaign, starttime, endtime, phone_number," & _
        " agent, notes, id) VALUES (@campaign, @starttime, @endtime, @phone_number, @agen" & _
        "t, @notes, @id); SELECT campaign, starttime, endtime, phone_number, agent, notes" & _
        ", id FROM callcenter_outbound_timer WHERE (id = @id)"
        Me.SqlInsertCommand1.Connection = Me.SqlConnection1
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@campaign", System.Data.SqlDbType.VarChar, 50, "campaign"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@starttime", System.Data.SqlDbType.DateTime, 8, "starttime"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@endtime", System.Data.SqlDbType.DateTime, 8, "endtime"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@phone_number", System.Data.SqlDbType.VarChar, 15, "phone_number"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@agent", System.Data.SqlDbType.VarChar, 20, "agent"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@notes", System.Data.SqlDbType.NVarChar, 500, "notes"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@id", System.Data.SqlDbType.UniqueIdentifier, 16, "id"))



 SqlConnection1.Open()
        SqlInsertCommand1.Parameters("@agent").Value = agent
        SqlInsertCommand1.Parameters("@campaign").Value = campaign
        SqlInsertCommand1.Parameters("@starttime").Value = starttime
        SqlInsertCommand1.Parameters("@endtime").Value = endtime
        SqlInsertCommand1.Parameters("@phone_number").Value = number
        SqlInsertCommand1.Parameters("@notes").Value = notes
        SqlInsertCommand1.ExecuteNonQuery()
        SqlConnection1.Close()



Thanks again

Danny
dnickelssaAsked:
Who is Participating?
 
vinhthuy_nguyenCommented:
Hi Danny,
Did you try to run directly in SQL Server ?
One thing, I see that your query seems not available for ExecuteNonQuery function, after insert record you select something.
Nice day
0
 
heintalusCommented:
Have you got

Imports System.Data.SqlClient

at the top of your class ?
0
 
dnickelssaAuthor Commented:
Yes I do have that at the top of my page.

Danny
0
 
heintalusCommented:
What is SqlInsertCommand1 declared as ?
0
 
dnickelssaAuthor Commented:
It was the select after the insert statement.  That is what I get  for letting the wizard do it for me.  I think that will be enough of that.

Thanks for you help vin

Danny
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.