|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
|
|
#1
|
|||
|
|||
|
writing to sql server
Hi everyone. I am trying to write to sql server with just one text field to test to see if what I have is working. I can pull up the fields so I know it is connecting but when I go to insert it is giving me this error:
MERANT][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'dbo.Table1' below is all the code from the page. anyone have any ideas??? <cfset CurrentPage=GetFileFromPath(GetTemplatePath())> <cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "form1"> <cfquery datasource="Vacancy"> INSERT INTO dbo.Table1 ("position") VALUES ( <cfif IsDefined("FORM.position") AND #FORM.position# NEQ ""> '#FORM.position#' <cfelse> NULL </cfif> ) </cfquery> </cfif> <cfquery name="Recordset1" datasource="Vacancy"> SELECT * FROM dbo.Table1 </cfquery> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <p> </p> <table border="1" cellpadding="2" cellspacing="2"> <tr> <td>position</td> <td>programmanager</td> <td>availability</td> <td>travel</td> <td>interview</td> <td>start</td> <td>type</td> <td>salary</td> <td>rate</td> <td>temp</td> <td>customer</td> <td>location</td> <td>workhours</td> <td>clearance</td> <td>duties</td> <td>experience</td> <td>new</td> </tr> <cfoutput query="Recordset1"> <tr> <td>#Recordset1.position#</td> <td>#Recordset1.programmanager#</td> <td>#Recordset1.availability#</td> <td>#Recordset1.travel#</td> <td>#Recordset1.interview#</td> <td>#Recordset1.start#</td> <td>#Recordset1.type#</td> <td>#Recordset1.salary#</td> <td>#Recordset1.rate#</td> <td>#Recordset1.temp#</td> <td>#Recordset1.customer#</td> <td>#Recordset1.location#</td> <td>#Recordset1.workhours#</td> <td>#Recordset1.clearance#</td> <td>#Recordset1.duties#</td> <td>#Recordset1.experience#</td> <td>#Recordset1.new#</td> </tr> </cfoutput> </table> <p> </p> <form method="post" name="form1" action="<cfoutput>#CurrentPage#</cfoutput>"> <table align="center"> <tr valign="baseline"> <td nowrap align="right">Position:</td> <td><input type="text" name="position" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td><input type="submit" value="Insert Record"></td> </tr> </table> <input type="hidden" name="MM_InsertRecord" value="form1"> </form> <p> </p> </body> </html> |
|
#2
|
|||
|
|||
|
Omit the dbo. prefix and try it again. Unless the account you are connecting to SQL Server with from CF is the dbo of that database, this will fail.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
tried it, didnt work, any ideas?
hey kiteless I appreciate your help. I took out the dbo strings and it didnt help. This is the error I got when I ran the page again. Any ideas?
Error Executing Database Query. [MERANT][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'Table1'. The Error Occurred in C:\Inetpub\wwwroot\Vacancy\TMP13gk21o3hb.cfm: line 11 9 : </cfif> 10 : ) 11 : </cfquery> 12 : </cfif> 13 : <cfquery name="Recordset1" datasource="Vacancy"> is ther epossibly a better way to write the insert code, or a specific way that sql likes better than others? |
|
#4
|
|||
|
|||
|
From the error, it appears that the user account that CF is using to access the SQL server can't "see" Table1. Are you sure there is a table called Table1 in the database? Have you given the account that CF is using permission to access that table? Have you set the default database for the account that CF is using to the desired database?
If CF has permission, you should be able to access the table by prefixing it with the database name, like "mydb.table1" assuming "mydb" is the name of the database where "table1" exists. But if you set the default database correctly you should not have to do this. |
|
#5
|
|||
|
|||
|
wow damn SQL
Kiteless - I appreciate your help. Yea man I am doing this for testing so I didnt name the db. anything butttt I fixed the problem. I had to go through the DB and make sure everything was set up perfectly or it wont do anything for me. The pkey wasn't enabled and upon import of the form to the web page it added some extra "" characters to some fields which messed it up also. but now I have it writing. Now onto some new tricks. I just picked up a copy of cold fusion two days ago so I am learning. I appreciate your help. i will be back for more questions probably some time soon. thanks.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > writing to sql server |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|