473,804 Members | 3,211 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Run time error on: objCommand.Exec uteNonQuery()

I just tried to create a simple ASP.NET application to add record to the SQL
Server database. However, it has run time error on Line 88:
objCommand.Exec uteNonQuery()

Any ideas?? Please help!! Thanks!!

Sub AddNewRecord()
Dim objConnection As SqlConnection
Dim strConnection As String = "Data Source=20.11.12 .91;Network
Library=DBMSSOC N;Initial Catalog=testtab le;User ID=sa;Password= iw;"
objConnection = New SqlConnection(s trConnection)
Dim objCommand As SqlCommand
Dim strSQLQuery As String
strSQLQuery = "INSERT INTO Test " _
& "(FirstName , LastName, SerialNumber) " _
& "VALUES (@TextValue, @TextValue, @TextValue)"
objCommand = New SqlCommand(strS QLQuery, objConnection)
objCommand.Para meters.Add(New SqlParameter("@ TextValue", SqlDbType.Char,
255))
objCommand.Para meters.Add(New SqlParameter("@ TextValue", SqlDbType.Char,
255))
objCommand.Para meters.Add(New SqlParameter("@ TextValue", SqlDbType.Char,
255))
objCommand.Para meters("@TextVa lue").Value = CStr(TextBox1.T ext)
objCommand.Para meters("@TextVa lue").Value = CStr(TextBox2.T ext)
objCommand.Para meters("@TextVa lue").Value = CStr(TextBox4.T ext)
objConnection.O pen()
objCommand.Exec uteNonQuery()
objConnection.C lose()
End Sub

Runtime error:

Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.Sql Client.SqlExcep tion: ?? ??
'@TextValue'?(? ) ?? ???????. ?? ??? ?? ?? ?? ?? ?? ???? ??? ???? ???.

Source Error:

Line 86: ' Open the connection, execute the command, and close the
connection.
Line 87: objConnection.O pen()
Line 88: objCommand.Exec uteNonQuery()
Line 89: objConnection.C lose()
Line 90:
Nov 17 '05 #1
1 4275
& "VALUES (@TextValue, @TextValue, @TextValue)"

should be:

& "VALUES ('@TextValue', '@TextValue', '@TextValue')"

notice the single-quotes

Hope this helps...

"Matthew Louden" <ma*******@hotm ail.com> wrote in message
news:uP******** *****@TK2MSFTNG P10.phx.gbl...
I just tried to create a simple ASP.NET application to add record to the SQL Server database. However, it has run time error on Line 88:
objCommand.Exec uteNonQuery()

Any ideas?? Please help!! Thanks!!

Sub AddNewRecord()
Dim objConnection As SqlConnection
Dim strConnection As String = "Data Source=20.11.12 .91;Network
Library=DBMSSOC N;Initial Catalog=testtab le;User ID=sa;Password= iw;"
objConnection = New SqlConnection(s trConnection)
Dim objCommand As SqlCommand
Dim strSQLQuery As String
strSQLQuery = "INSERT INTO Test " _
& "(FirstName , LastName, SerialNumber) " _
& "VALUES (@TextValue, @TextValue, @TextValue)"
objCommand = New SqlCommand(strS QLQuery, objConnection)
objCommand.Para meters.Add(New SqlParameter("@ TextValue", SqlDbType.Char,
255))
objCommand.Para meters.Add(New SqlParameter("@ TextValue", SqlDbType.Char,
255))
objCommand.Para meters.Add(New SqlParameter("@ TextValue", SqlDbType.Char,
255))
objCommand.Para meters("@TextVa lue").Value = CStr(TextBox1.T ext)
objCommand.Para meters("@TextVa lue").Value = CStr(TextBox2.T ext)
objCommand.Para meters("@TextVa lue").Value = CStr(TextBox4.T ext)
objConnection.O pen()
objCommand.Exec uteNonQuery()
objConnection.C lose()
End Sub

Runtime error:

Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.Sql Client.SqlExcep tion: ?? ??
'@TextValue'?(? ) ?? ???????. ?? ??? ?? ?? ?? ?? ?? ???? ??? ???? ???.

Source Error:

Line 86: ' Open the connection, execute the command, and close the connection.
Line 87: objConnection.O pen()
Line 88: objCommand.Exec uteNonQuery()
Line 89: objConnection.C lose()
Line 90:

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
12648
by: Barry Young | last post by:
I am using the following code to insert a row in an Oracle Database. strConnection = "Provider=OraOLEDB.Oracle;Data Source=MYDATABASE;User Id=SYSTEM;Password=******" Dim strMessage As String Dim objConnection As New OleDb.OleDbConnection(strConnection) Dim objCommand As OleDb.OleDbCommand
0
5751
by: Aaron_TekRecycle.com | last post by:
this runs perfectly as a .vbs but I'd like to convert it to an ASP... any ideas? Response.Buffer = True Dim objConnection, objCommand, objRecordSet Dim oPrinterName, oServerName Const ADS_SCOPE_SUBTREE = 2 Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command")
0
2151
by: sunmiester | last post by:
I have an ASP page that retrieves user info. The page runs fine on XP Pro IIS 5.1, however, when i try to run it from a server running W2k Server SP4 or W2K3, it breaks and i get the following error: Error Type: Microsoft VBScript runtime (0x800A000D) Type mismatch Code:
0
1293
by: abdul haleem | last post by:
hiye guys, can anyone tell me whats wrong with this piece of code? to my knowledge, its looks and seems fine. i'm very puzzle by this error. i get this error msg "Operation must use an updateable query." anyone knows what it means? below is the code
2
2853
by: Joe | last post by:
Hello All, I am trying to insert a record in the MS Access DB and for some reason I cannot get rid of error message, System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. And the line it shows in red is cmd.ExecuteNonQuery()
1
5427
by: Joe | last post by:
Hello All, I am trying to insert a record in the MS Access DB and for some reason I cannot get rid of error message, System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. And the line it shows in red is cmd.ExecuteNonQuery()
2
2067
by: darrel | last post by:
I'm trying to delete a record in a table: Dim strConnect As String = System.Configuration.ConfigurationSettings.AppSettings("myConnectionString") Dim strChk = "DELETE FROM we_admin_users WHERE UserID='" & myUserID & "'" Dim objConnect As New System.Data.OleDb.OleDbConnection(strConnect) objConnect.Open() Dim objCommand As New System.Data.OleDb.OleDbCommand(strChk, objConnect) objCommand.ExecuteNonQuery()
3
3318
by: Jim in Arizona | last post by:
I have a gridview that's being populated from an access db query. The problem I'm having is that the date/time fields in access that are populating the gridview are showing both date and time, when the field should only be showing one or the other (date or time). Even on the back end of the database where the column properties are, I have chosen the smallest date/time formats. When the aspx page runs, it shows the date and time (ie:in a...
1
3557
by: Jim | last post by:
I'm trying to take the data from strSQL below and "append / insert" that into the Access database. The problem is: although the listbox displays correctly, the Access table gets the first record inserted to the table multiple times - as many rows as there are in the source table. Obviously the Access parameters aren't getting updated properly. I've tried putting the .parameters.Add outside the for - next loop. No joy. Also, if...
0
9707
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5658
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.