473,662 Members | 2,704 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=localhos t;integrated security=true;i nitial
catalog=DemoCRQ database")
'command
Dim propertyCMD As New SqlCommand("INE RT INTO " &
txtProperty.Tex t & "(Code, Name) VALUES(" & txtCode.Text & ", " &
txtName.Text & ")", conn)
'command type: CommandType.Tex t
propertyCMD.Com mandType = CommandType.Tex t
'Open connection and execute the insert statement
conn.Open()
propertyCMD.Exe cuteNonQuery()
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.Sql Client.SqlExcep tion: Incorrect syntax near
the keyword 'INTO'.

Source Error:
Line 66: propertyCMD.Com mandType = CommandType.Tex t
Line 67: 'Open connection and execute the insert statement
Line 68: conn.Open()
Line 69: propertyCMD.Exe cuteNonQuery()
Line 70: conn.Close()
Source File: c:\inetpub\wwwr oot\Demo\AddCla ssProperty.aspx .vb Line: 68

Oct 23 '06 #1
3 1653
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=localhos t;integrated security=true;i nitial
catalog=DemoCRQ database")
'command
Dim propertyCMD As New SqlCommand("INE RT INTO " &
txtProperty.Tex t & "(Code, Name) VALUES(" & txtCode.Text & ", " &
txtName.Text & ")", conn)
'command type: CommandType.Tex t
propertyCMD.Com mandType = CommandType.Tex t
'Open connection and execute the insert statement
conn.Open()
propertyCMD.Exe cuteNonQuery()
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.Sql Client.SqlExcep tion: Incorrect syntax near
the keyword 'INTO'.

Source Error:
Line 66: propertyCMD.Com mandType = CommandType.Tex t
Line 67: 'Open connection and execute the insert statement
Line 68: conn.Open()
Line 69: propertyCMD.Exe cuteNonQuery()
Line 70: conn.Close()
Source File: c:\inetpub\wwwr oot\Demo\AddCla ssProperty.aspx .vb Line: 68
Oct 23 '06 #2
"david" <da***@discussi ons.microsoft.c omwrote in message
news:FB******** *************** ***********@mic rosoft.com...
Dim propertyCMD As New SqlCommand("INE RT 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=localhos t;integrated security=true;i nitial
catalog=DemoCRQ database")
'command
Dim propertyCMD As New SqlCommand("INE RT INTO " &
txtProperty.Tex t & "(Code, Name) VALUES(" & txtCode.Text & ", " &
txtName.Text & ")", conn)
'command type: CommandType.Tex t
propertyCMD.Com mandType = CommandType.Tex t
'Open connection and execute the insert statement
conn.Open()
propertyCMD.Exe cuteNonQuery()
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.Sql Client.SqlExcep tion: Incorrect syntax near
the keyword 'INTO'.

Source Error:
Line 66: propertyCMD.Com mandType = CommandType.Tex t
Line 67: 'Open connection and execute the insert statement
Line 68: conn.Open()
Line 69: propertyCMD.Exe cuteNonQuery()
Line 70: conn.Close()
Source File: c:\inetpub\wwwr oot\Demo\AddCla ssProperty.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 trouble making it work in SQL Server 2000. I am not a database newbie, but I can't seem to figure this one out so I am turning to the newsgroup. I am thinking that some of the SQL Gurus out there have done this very thing a thousand times before...
0
1746
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 insert or update pages don't always work now on some records . . . It seems that when lots of text is shoved into a memo fields the database ID for that record gets messed up. Intial record insertion goes OK, but updating is then hosed.
3
1091
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 holds their answers. Let make it simple, the questions are Name: Address
2
2907
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 avoid the problem by avoiding the table control or resorting to databound controls that better manage state for me. I hope to understand how to solve the problem by using the Table web control and sticking to the approach of building the table at run...
3
3441
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 the necessary records in it when testing it. I get the error "No value given for one or more required parameters." when I try to update the database. Can you tell me what am I doing wrong?
6
4985
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 for long running reports. When the processing is complete it uses crystal reports to load a template file, populate it, and then export it to a PDF. It works fine so far....
1
4217
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"%> <!--#include virtual="/Connections/EmployeeStatusChange.asp" --> <%
15
2569
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 determine who needs to receive the text message then send the message to the address. Only problem is, the employee may receive up to 4 of the same messages because each thread gets the recors then sends the message. I need somehow to prevent...
4
14122
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 I have two table: - master(id, field1, field2, ...) - detail(id0, id, progr, data, sede, esecutori, brani_autori) in a master-detail relation with "id" as foreign key. The fields of the "detail" table are:
14
2440
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 code to C. I really need this so thatr i can learn my mistakes in C. Below is the C++ code that i have have developed. Thank you, #include<fstream> #include<string> #include<iostream> #include<iomanip> using namespace std; struct employee{...
0
8435
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...
1
8547
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
8633
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
7368
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...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4181
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4348
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2763
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
1999
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.