Click to See Complete Forum and Search --> : Error in writing to a database
Cheryl399
05-07-2010, 02:21 AM
Hello everyone,
Im trying to write to a database but i keep getting an error, for some reason it doesnt like my connection string:
ADODB.Command (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
My code is:
Set strCon = Server.CreateObject ("ADODB.Command")
strCon.ActiveConnection = MM_MyDSN_STRING <Stops at this line
Any help would be appreciated
Thanks :)
yamaharuss
05-07-2010, 06:40 AM
Please show all of your code. Especially where MM_MyDSN_STRING is defined.
Gullanian
05-07-2010, 07:35 AM
before:
strCon.ActiveConnection = MM_MyDSN_STRING
Put:
response.write MM_MyDSN_STRING
response.end
then paste result in here omitting any sensitive information that might possibly be included.
Cheryl399
05-07-2010, 07:49 AM
here is all of my code and shows where the connection string is defined:
<%
<!-- #include virtual="testproject/common/adovbs.inc" -->
<!--#include file="Connections/MyDSN.asp" -->
Dim Problem_ID
Dim Priotiy_Level
Dim Problem_Site
Dim Problem_Description
Dim Problem_Status
Dim Job_Status
Dim Tempvar1, Tempvar2, Tempvar3, Tempvar4, Tempvar5, Tempvar6
Dim UserRequestRS
Dim strConn
Dim strSQL
Dim MM_MyDSN_STRING
Tempvar1 = Request.Form("ProblemID")
Tempvar2 = Request.Form("PriotiyLevel")
Tempvar3 = Request.Form("ProblemSite")
Tempvar4 = Request.Form("ProblemDescription")
Tempvar5 = Request.Form("ProblemStatus")
Tempvar6 = Request.Form("JobStatus")
Response.write "<p> " & Tempvar1 & " </p>"
Response.write "<p> " & Tempvar2 & " </p>"
Response.write "<p> " & Tempvar3 & " </p>"
Response.write "<p> " & Tempvar4 & " </p>"
Response.write "<p> " & Tempvar5 & " </p>"
Response.write "<p> " & Tempvar6 & " </p>"
Set strConn = Server.CreateObject ("ADODB.Connection")
response.write MM_MyDSN_STRING
response.end
strConn.ConnectionString = MM_MyDSN_STRING
set UserRequestRS = Server.Createobject("ADODB.Recordset")
strSQL= "SELECT * FROM DeskTable"
strConn.open
UserRequestRS.Open strSQL, strConn, 3,2
UserRequestRs.AddNew
UserRequestRs.Update
UserRequestRs.Fields("Problem_ID").value= ProblemID
UserRequestRs.Fields("Priotiy_Level").value= PriotiyLevel
UserRequestRs.Fields("Problem_Site").value= ProblemSite
UserRequestRs.Fields("Problem_Description").value= ProblemDescription
UserRequestRs.Fields("Problem_Status").value= ProblemStatus
UserRequestRs.Fields("Job_Status").value= JobStatus
UserRequestRs.Update
SQL= "INSERT INTO DeskTable (Problem_ID,Priotiy_Level,Problem_Area,Problem_Description,Problem_Status,Job_Status)"
SQL= SQL & " VALUES "
SQL= SQL & "(" & Problem_ID & "',"
SQL= SQL & "'" & Priotiy_Level & "',"
SQL= SQL & "'" & Problem_Site & "',"
SQL= SQL & "'" & Problem_Description & "',"
SQL= SQL & "'" & Problem_Status & "',"
SQL= SQL & "'" & Job_Status & "')"
strConn.Execute SQL
Response.Write("Thank you for your request")
set UserRequestRS = nothing
Set strConn = Nothing
%>
Gullanian the results from the responce.write shows the information inputted from my form which displayed correctly
Gullanian
05-07-2010, 08:00 AM
Between the line in question and the declaration of the variable there is apparently no code assigning a value to the variable?
Cheryl399
05-07-2010, 08:04 AM
:confused: sorry im lost i thought there was
Gullanian
05-07-2010, 08:05 AM
Dim MM_MyDSN_STRING
...
strConn.ConnectionString = MM_MyDSN_STRING
Between those two lines there is no code that actually sets MM_MyDSN_STRING to contain any values! So it's trying to connect using a blank connection string.
Cheryl399
05-07-2010, 08:12 AM
sorry i forgot to include that in the code i sent over, the MM_MyDSN_STRING is in a include file which i have specified in my asp as.....
<!--#include file="Connections/MyDSN.asp" -->
as far as i know i have database connectivity as i tested this through dreamweaver but just not writing
Gullanian
05-07-2010, 08:14 AM
Look, what I'm trying to do is get you to print out the value of that variable, because there is a syntax error in it, or some sort of invalid value.
Print out the value of the variable the line before it crashes, but make sure you replace any password or IP address with something like PASSWORD or IPADDRESS so that you don't publish anything sensitive.