Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trouble with INSERT INTO

Status
Not open for further replies.

compi

Programmer
Apr 6, 2001
3
0
0
CH
I try to get the Information of a Form into a Table and I always get error 37000
Here is the code:

<cfquery name=&quot;db_eintrag&quot; datasource=&quot;Forum&quot; dbtype=&quot;ODBC&quot;>
INSERT INTO tblForum (ParentID, IP, Name, email, Betreff, Text)
VALUES (#Form.ParentID#, '#Form.IP#', '#Form.Name#', '#Form.email#', '#Form.Betreff#', '#Form.Text#')
</cfquery>
 
Here are some guidelines to help you,

1. Whenever possible, use <CFINSERT> to add data to ODBC tables.

2. If you find that you need to add specific form fields and not all that were submitted - you can use the <CFINSERT> tag with the FORMFIELDS attribute.

3. If <CFINSERT> cannot be used because you need a complex INSERT statement or are using fields that are not form fields, use SQL INSERT.

Bye
Johnson
 
I disagree with Mic. CFINSERT is a quick way to get errors. When possible, use SQL. Become very familiar with SQL... Its your friend. :)

I think your prob is that you're not wrapping the &quot;ParentID&quot; with single quotes. Even though you have it specified as an INT (maybe), you should still thow some single quotes around it - but only for INSERT INTO.

Here ya go... Try this:

Code:
<cfquery name=&quot;db_eintrag&quot; datasource=&quot;Forum&quot; dbtype=&quot;ODBC&quot;>
INSERT INTO tblForum (ParentID, IP, Name, email, Betreff, Text)
VALUES ('#Form.ParentID#', '#Form.IP#', '#Form.Name#', '#Form.email#', '#Form.Betreff#', '#Form.Text#') 
</cfquery>

Try that.

Ryan
 
If you set the datatype ParentID as an integer in your SQL table u should not wrap it up wif a single quote

<cfquery name=&quot;db_eintrag&quot; datasource=&quot;Forum&quot; dbtype=&quot;ODBC&quot;>
INSERT INTO tblForum (ParentID, IP, Name, email, Betreff, Text)
VALUE(#form.ParentID#, '#form.IP#', '#form.Name#', '#form.email#', '#form.Betreff#', '#form.Text#')
</cfquery>

If you have set your datatype for ParentID as a text or ntext or characters then u should do this...see below

<cfquery name=&quot;db_eintrag&quot; datasource=&quot;Forum&quot; dbtype=&quot;ODBC&quot;>
INSERT INTO tblForum (ParentID, IP, Name, email, Betreff, Text)
VALUES ('#form.ParentID#', '#form.IP#', '#form.Name#', '#form.email#', '#form.Betreff#', '#form.Text#')
</cfquery>

If this doesn't work.pls copy and paste ur error msg.......in this way.it would be much clearer

Cheers
alisha


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top