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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JS / ASP Connection problem 1

Status
Not open for further replies.

kyjoey

Technical User
Jun 6, 2005
23
US
Hey all, I am having trouble with the following connection:

var strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=\\\\T03web01\\AreaWebs\\" +
"Quality\\QA\\Systems\\TPD\\database\\tpd.mdb"; //Connection String var adoConnection = Server.CreateObject("ADODB.Connection");
var mySQL = "INSERT INTO users (user_Id, tm_Number, lname, fname, password, Access) Values ('test',12345,'testfirst','testlast','vader2',1)
";
adoConnection.Open(strConnection);
var adoRecordset = Server.CreateObject("ADODB.Recordset");
adoRecordset=adoConnection.Execute(mySQL);

When I do the same string for delete or update it works! I cannot add a new record. Any ideas anyone?

-Joey
 
I think you are running in to a 'reserved word' issue. Try this...

Code:
var mySQL = "INSERT INTO users ([user_Id], [tm_Number], [lname], [fname], [password], [Access]) Values ('test',12345,'testfirst','testlast','vader2',1)

I'm sure that not all those field names are reserved words, but password and/or access may be. By putting the square brackets around the field names, you can use reserved words.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Bingo! That nailed it! Muchos Gracias amigo.



-Joey
 
da nada.

I think it is considered 'best practices' to NOT name your tables and fields the same as something on the reserved word list. If you are near the beginning of the project, I recommend changing the field names. Anyway, I'm glad to have helped and I'm glad you got things working.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
George,

I now have the following similar but different issue:

The following code successfully inserts the data, but gives me an error.

Code:
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%> <% var strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=\\\\T03web01\\AreaWebs\\" +
 "Quality\\QA\\Systems\\TPD\\database\\tpd.mdb"; //Connection String var adoConnection = Server.CreateObject("ADODB.Connection");
var nu_m = parseInt(4);
var lev = String("qe");
var mySQL = "INSERT INTO access_Levels ([value], [level]) VALUES ("+nu_m+",'"+lev+"')"; adoConnection.Open(strConnection);
var adoRecordset = Server.CreateObject("ADODB.Recordset");
adoRecordset=adoConnection.Execute(mySQL);

adoRecordset.Close();
adoRecordset = null;
adoConnection.Close();
adoConnection = null;
%>
Could you help me to what I am not doing or something I am missing?

Thanks again,
Joey

-Joey
 
Nope. Can't help. Your first problem was a database problem, which I'm familar with. Your second problem doesn't appear to be database related (because the data actually inserts ok). I do not know javascript. Not even a little. In fact, the only reason I know this is javascript is because I know how to read (@LANGUAGE="JAVASCRIPT").

Luckily for you, there are some javascript experts around here that can help you better than I can. In fact, there's an entire forum dedicated to javascript.


-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Thanks anyway George! I will ask them. :)

-Joey
 
Now that I think about this a little more, I notice that you are using a recordset object. You don't need to. Recordset objects are used when you return data from the database. Your query is not returning any data, so remove the recordset object completely from this code. It may not be the solution, but it couldn't hurt to try.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
The web page only says "Internal Server Error"

-Joey
 
did you have this line commented:

//Connection String var adoConnection = Server.CreateObject("ADODB.Connection");
??

if so you have to uncomment it...
you only need a connection object and not a recordset object...
-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top