Jump to content

Foiled again!


Eivo

Recommended Posts

Ok, I am still working in my endeavor to connect to this database. Here is all the code there is on my page to connect. I got the connection string and everything from the db admin along with the file location. But this is the error I get...

Microsoft JScript compilation error '800a03ec'Expected ';'/Test/connection_test.asp, line 10set conn=Server.CreateObject("ADODB.Connection")----^
I pasted that into the ms site and got thishttp://support.microsoft.com/kb/190940I guess what I'm asking is what am I doing wrong. It says that it's a bug. That mean I'm screwed or is there a work around or another method I can connect with? Thanks in advance for your help.
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Title Bar!</title></head><%set conn=Server.CreateObject("ADODB.Connection")conn.Provider=sqloledb;Data Source=mssql08.1and1.com,1433;Initial Catalog=db186589768;User Id=dbo186589768;Password=dummypassword;conn.Open "E:\MSSQL2000\MSSQL\Data\\db186589768.mdf"conn.Close%><body></body></html>

Link to comment
Share on other sites

Since you are using Javascript, you might try changing that line to look more like this:

var conn = Server.CreateObject("ADODB.Connection");

Note the semi-colon at the end and the use of var rather than set.

Link to comment
Share on other sites

Ahh, I am almost there. Major changes to the code cause I'm an idiot. I have it written in javascript now. I can connect to the database and even right to it! But I can't seem to write what I want to it. Here is the code.

<%var myConnection = "Provider=sqloledb; Data Source=mssql08.1and1.com,1433; Initial Catalog=db186589768; User Id=dbo186589768; Password=password;"var connectionObject = Server.CreateObject("ADODB.Connection");var placeAuthor = new String(Request.Form("writeAuthor"))var placeTitle = new String(Request.Form("writeTitle"))var placeStory = new String(Request.Form("writeStory"))Response.Write(placeAuthor)Response.Write("<br />")Response.Write(placeTitle)Response.Write("<br />")Response.Write(placeStory)Response.Write("<br />")sql = "INSERT INTO mfvfd (author,title,story) Values ('placeAuthor','placeTitle','placeStory');"connectionObject.Open (myConnection)connectionObject.Execute(sql)connectionObject.Close()connectionObject = null;%>

I know it has something to do with the sql line in Values. It thinks that I want to write "placeAuthor" when I really want to write the var placeAuthor. My table is full of placeAuthor, placeTitle, and placeStory 's. How to I get it to recognize that it is the var I want?

Link to comment
Share on other sites

I should have stated, when I put the var in the Value() without any quotes or double quotes I get an error...Microsoft OLE DB Provider for SQL Server error '80040e14'The name 'placeAuthor' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted./Test/connection_test.asp, line 29

Link to comment
Share on other sites

It can open you up to SQL Injection attacks, but I believe you're looking for something like this:

sql = "INSERT INTO mfvfd (author,title,story) Values ('";sql += placeAuthor + "','" + placeTitle + "','" + placeStory + "');"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...