Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Name 'ExecuteNonQuery' is not declared error when doing insert

Posted on 2004-11-01
5
Medium Priority
?
362 Views
Last Modified: 2006-11-17
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
0
Comment
Question by:dnickelssa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 10

Expert Comment

by:heintalus
ID: 12466128
Have you got

Imports System.Data.SqlClient

at the top of your class ?
0
 

Author Comment

by:dnickelssa
ID: 12466239
Yes I do have that at the top of my page.

Danny
0
 
LVL 4

Accepted Solution

by:
vinhthuy_nguyen earned 2000 total points
ID: 12470499
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
 
LVL 10

Expert Comment

by:heintalus
ID: 12476009
What is SqlInsertCommand1 declared as ?
0
 

Author Comment

by:dnickelssa
ID: 12478633
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question