Dsn

shuli

Guppy
Hello everyone,
I have a DB project in ASP to do, I am a beginner, and I am stuck in a problem. I will apprecuate it very much if anyone that can help would do that.

We are working with a web server in which DSN is not installed. (Is it necessary to install it?)
I have been searching the web for whole days to find an example of insertion to DB without using DSN.
To be exact, I did find such examples, but I did not see the way of connecting the DB (the .mdb page itself), just the way of accessing the table, so it doesn't know where to take the table from, so none of them worked.

Again, I thank everyone who whould try to help, it is really important for me.
 
You can use access with no DSN with a string like this:
Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydatabase.mdb;Uid=Admin;Pwd=;"

If you need help with something else it would probably be best to paste the code and edit out and sensitive parts.
 
Thank you Stephen and KCWebMonkey for your help, I do manage to connect to DB without using dsn.
However, for some reason, I still can't insert a record to the DB...
For example, if I use the code given here
http://www.aspwebpro.com/aspscripts/records/insertnew.asp
I am stuck with the line :
<!--#INCLUDE VIRTUAL="/includes/connection.asp" -->
which doesn't seem to work (if I add it on the second line of the page, right after <%@ Language=VBScript %> or inside the BODY part of the page... it doesn't matter, it makes problems in the page)
and I've tried many examples and none of them worked.

Do you know where I can find a (good) code for inserting a record to DB?

Thanks again.
 
try using an include FILE instead of virtual, I have seen this issue a few times.
 
Well... haven't solved my problem yet...
If anyone will have an idea... here is a simple code (from here http://support.microsoft.com/kb/q188713/)

but when it gets to the last line(update) , there is an error on the page.

Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "MyTable", conn, 1, 3, 2 ' Make sure the LockType
' allows for insertions and updates
' Insert a record
rs.AddNew
rs("Field1") = Value1
rs.Update
 
Hi, this is the file page5.asp

<!--#include file="dsn.asp"-->
<%

dim first,last
first=Request.QueryString("fname")
last=Request.QueryString("lname")
score=Request.QueryString("totalscore")

set c=Server.CreateObject("adodb.connection")
c.Open dsn

'Set rs = Server.CreateObject("ADODB.Recordset")
' rs.Open "grades", c, 1, 3, 2 ' Make sure the LockType
'rs.AddNew
'rs("fname") = first
rs.Update()

'second option I tried
'c.Execute("INSERT INTO grades(fname) VALUES (first)")

'c.close
%>

that's it.
(grades, for now, is a one-column-table and it's name is fname ( of type - text) . the DB name is results. Now I will paste the code of the dsn.asp file)

<%
dim dsn
dim Conn
dsn="DBQ=" & Server.Mappath("results.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open dsn
%>

Thank you for any help.
Shuli.
 
Back
Top