473,507 Members | 13,917 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help: Insert record into database

I have following code, but I do not know where the problem is. Thank you for
any help.

David

----Code---
'connection
conn = New SqlConnection _
("data source=localhost;integrated security=true;initial
catalog=DemoCRQdatabase")
'command
Dim propertyCMD As New SqlCommand("INERT INTO " &
txtProperty.Text & "(Code, Name) VALUES(" & txtCode.Text & ", " &
txtName.Text & ")", conn)
'command type: CommandType.Text
propertyCMD.CommandType = CommandType.Text
'Open connection and execute the insert statement
conn.Open()
propertyCMD.ExecuteNonQuery()
conn.Close()

----
----error message-----
Incorrect syntax near the keyword 'INTO'.
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.SqlClient.SqlException: Incorrect syntax near
the keyword 'INTO'.

Source Error:
Line 66: propertyCMD.CommandType = CommandType.Text
Line 67: 'Open connection and execute the insert statement
Line 68: conn.Open()
Line 69: propertyCMD.ExecuteNonQuery()
Line 70: conn.Close()
Source File: c:\inetpub\wwwroot\Demo\AddClassProperty.aspx.vb Line: 68

Oct 23 '06 #1
3 1648
INERT is spelled INSERT.

Do use stored procedues over direct queries.
The presented code is really open to injection attacks!

--
rgds.
/Claus Konrad
"david" wrote:
I have following code, but I do not know where the problem is. Thank you for
any help.

David

----Code---
'connection
conn = New SqlConnection _
("data source=localhost;integrated security=true;initial
catalog=DemoCRQdatabase")
'command
Dim propertyCMD As New SqlCommand("INERT INTO " &
txtProperty.Text & "(Code, Name) VALUES(" & txtCode.Text & ", " &
txtName.Text & ")", conn)
'command type: CommandType.Text
propertyCMD.CommandType = CommandType.Text
'Open connection and execute the insert statement
conn.Open()
propertyCMD.ExecuteNonQuery()
conn.Close()

----
----error message-----
Incorrect syntax near the keyword 'INTO'.
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.SqlClient.SqlException: Incorrect syntax near
the keyword 'INTO'.

Source Error:
Line 66: propertyCMD.CommandType = CommandType.Text
Line 67: 'Open connection and execute the insert statement
Line 68: conn.Open()
Line 69: propertyCMD.ExecuteNonQuery()
Line 70: conn.Close()
Source File: c:\inetpub\wwwroot\Demo\AddClassProperty.aspx.vb Line: 68
Oct 23 '06 #2
"david" <da***@discussions.microsoft.comwrote in message
news:FB**********************************@microsof t.com...
Dim propertyCMD As New SqlCommand("INERT INTO " &
Well, at the risk of appearing patronising, if you change "INERT" to
"INSERT", it might work... ;-)
Oct 23 '06 #3
Thank you both of you. Misspelling made me crazy.

David

"david" wrote:
I have following code, but I do not know where the problem is. Thank you for
any help.

David

----Code---
'connection
conn = New SqlConnection _
("data source=localhost;integrated security=true;initial
catalog=DemoCRQdatabase")
'command
Dim propertyCMD As New SqlCommand("INERT INTO " &
txtProperty.Text & "(Code, Name) VALUES(" & txtCode.Text & ", " &
txtName.Text & ")", conn)
'command type: CommandType.Text
propertyCMD.CommandType = CommandType.Text
'Open connection and execute the insert statement
conn.Open()
propertyCMD.ExecuteNonQuery()
conn.Close()

----
----error message-----
Incorrect syntax near the keyword 'INTO'.
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.SqlClient.SqlException: Incorrect syntax near
the keyword 'INTO'.

Source Error:
Line 66: propertyCMD.CommandType = CommandType.Text
Line 67: 'Open connection and execute the insert statement
Line 68: conn.Open()
Line 69: propertyCMD.ExecuteNonQuery()
Line 70: conn.Close()
Source File: c:\inetpub\wwwroot\Demo\AddClassProperty.aspx.vb Line: 68
Oct 24 '06 #4

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

Similar topics

0
482
by: Preston Landers | last post by:
Hello all. I am trying to write a query that "just" switches some data around so it is shown in a slightly different format. I am already able to do what I want in Oracle 8i, but I am having...
0
1741
by: htmlgeek | last post by:
I'm adding and updating records in an Access .mdb via WWW .asp page. Authored in Dreamweaver 2004 MX. Help is welcome on this one. I have a great set of pages that work fine, but it seems that...
3
1084
by: Hai Nguyen | last post by:
Hi everyone I'm devloping a wep application which needs to access database frequently (for now access database). I got stuck. The first page, I ask for several questions from customers and...
2
2893
by: Chad | last post by:
I have a problem that I am desperate to understand. It involves dynamically adding controls to a Table control that is built as a result of performing a database query. I am not looking to...
3
3426
by: Shapper | last post by:
Hello, I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine. The update is not. I checked and my database has all...
6
4960
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
1
4201
by: JNariss | last post by:
Hello, I have created a connection to my Access database with Dreamweaver and made a simple form with 4 fields. The code behind this form was/is: <%@LANGUAGE="VBCRIPT" CODEPAGE="1252"%>...
15
2551
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to...
4
14099
by: Tonio Tanzi | last post by:
I have the following problem in a Win 2000 Server + SQL Server 2000 environment and I hope somewhat can help me to resolve it (after many days of useless attempts I am desperate). In my database...
14
2426
by: optimum | last post by:
hi i am kind of new to programming, i have managed to create a simple payroll database in C++, but now i am trying to convert in into C but i am keep getting error, can anyone help me convert this...
0
7221
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,...
0
7109
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7372
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...
0
7481
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...
0
5619
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,...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1537
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 ...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
411
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...

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.