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

DSNLess Connection HELP!

Status
Not open for further replies.

lukechapman

Programmer
Joined
Oct 23, 2001
Messages
5
Location
GB
Hi,
I'm very new to asp (this morning infact) and I've been passed over a database connectivity problem. I want to set up a DSNLess connection but I'm not completely sure how, can you please help!

The script I want to amend follows:
*************************************************
<!-- #INCLUDE FILE=&quot;dsn.inc&quot; -->
<%
Dim db 'the database connection object
Dim rs 'recordset, for select statements
Dim cmd 'a command object, for inserts, updates and deletes


Function DbInit
Set db = Server.CreateObject(&quot;ADODB.Connection&quot;)
db.Open strConnect

Set rs = Server.CreateObject (&quot;ADODB.RecordSet&quot; )
rs.ActiveConnection = db
rs.CursorType = adOpenForwardOnly
rs.LockType = adLockReadOnly

Set cmd = Server.CreateObject (&quot;ADODB.Command&quot; )
cmd.CommandType = adCmdText
Set cmd.ActiveConnection = db
End Function


Function DbUpdateNotice(aId, aTitle, aText, aContrib, aExpiryCode)
Dim sTitle, sText, sContrib
sTitle = replace(aTitle,&quot;'&quot;,&quot;''&quot;)
sText = replace(aText,&quot;'&quot;,&quot;''&quot;)
sContrib = replace(aContrib,&quot;'&quot;,&quot;''&quot;)
cmd.CommandText = &quot;update Notices &quot; _
& &quot; set Title='&quot; & sTitle & &quot;', Contributor='&quot; & sContrib & &quot;',&quot; _
& &quot; [Text]='&quot; & sText & &quot;',Expiry='&quot; & aExpiryCode & &quot;'&quot; _
& &quot; where Id=&quot; & Request(&quot;aId&quot;)
cmd.Execute
End Function

Function DbInsertNotice(aGroupType, aGroupCode, aTitle, aText, aContrib, aExpiryCode)
Dim sTitle, sText, sContrib
sTitle = replace(aTitle,&quot;'&quot;,&quot;''&quot;)
sText = replace(aText,&quot;'&quot;,&quot;''&quot;)
sContrib = replace(aContrib,&quot;'&quot;,&quot;''&quot;)
cmd.CommandText = &quot;Insert into Notices&quot; _
& &quot;(GroupType,GroupCode,Title,[Text],Contributor,Expiry) &quot; _
& &quot; values('&quot; & aGroupType & &quot;','&quot; & aGroupCode &&quot;','&quot; & sTitle & &quot;','&quot; & sText & &quot;','&quot; _
& sContrib & &quot;','&quot; & aExpiryCode & &quot;')&quot;
cmd.Execute
End Function

Function DbDeleteNotice(aId)
cmd.CommandText = &quot;delete from Notices where Id=&quot; & aId
cmd.Execute
End Function

Function DbDeleteNotices(aIdList)
cmd.CommandText = &quot;delete from Notices where Id in (&quot; & aIdList & &quot;)&quot;
cmd.Execute
End Function

Function TimeStamp
TimeStamp = Year(Now()) & Month(Now()) & Day(Now()) & Hour(Now()) & Minute(Now()) & Second(Now())
End Function

Function FileExt(filename)
FileExt = Right(filename,len(filename)-instrRev(filename,&quot;.&quot;)+1)
End Function

Sub DbInsertAttachment(aClientFilename, aServerFilename, aDocTitle, aPupilId, aDocType, aFileSize, aAddedBy)
Dim sDocTitle,sql
sDocTitle = replace(aDocTitle,&quot;'&quot;,&quot;''&quot;)
sql = &quot;Insert into Attachments&quot; _
& &quot;(ServerFilename,ClientFilename,PupilId,DocTitle,DocType,FileSize,AddedBy) &quot; _
& &quot; values('&quot; & aServerFilename & &quot;','&quot; & aClientFilename &&quot;','&quot; & aPupilId & &quot;','&quot; & sDocTitle & &quot;','&quot;_
& aDocType & &quot;',&quot; & aFileSize & &quot;,'&quot; & aAddedBy & &quot;')&quot;
cmd.CommandText = sql
cmd.Execute
End Sub

Sub DbMarkVisit(aUserId,aUserRole)
cmd.CommandText = &quot;update Users set DateLastAccessed=Now() &quot; _
& &quot; where Id='&quot; & aUserId & &quot;' and Role='&quot; & aUserRole & &quot;'&quot;
cmd.Execute
End Sub

Function DbClose
Set rs = Nothing
Set cmd = Nothing
Set db = Nothing
End Function

Function ExtractFilenameOnly(aFilename)
' NB. THIS IS DESIGNED TO WORK WITH DOS PATHS (BACKSLASHES) ONLY
Dim ipos, s
' 1. Find and remove any file extension
s = aFilename
ipos = InStrRev(s, &quot;.&quot;)
If ipos > 0 Then
s = Left(s, ipos-1)
End If
' 2. Find and remove any path
ipos = InStrRev(aFilename, &quot;\&quot;)
If ipos > 0 Then
s = Right(s, Len(s)-ipos)
End If
ExtractFilenameOnly = s
End Function

%>
*************************************************

The dsn.inc is as follows:
*************************************************
<%
Dim strConnect
strConnect = &quot;File Name=e:\websites\bhs4parents\pmxl.udl&quot;
%>
*************************************************

and pmxl.udl is as follows:
*************************************************
[oledb]
; Everything after this line is an OLE DB initstring
Provider=Microsoft.Jet.OLEDB.4.0;Password=&quot;&quot;;Data Source=E:\db\pmxl.mdb;Persist Security Info=True
**************************************************


Your help would be very much appreciated!!!

Thank you.
 
By the way, the error I'm currently getting is:
Microsoft JET Database Engine error '80004005'
Unspecified error
/common_asp.inc, line 10

It's an sql error, right?
The thing is that the script works on one server but not on the one I want to put it on - everythings been set up the same but it just doesn't want to work!

Thanks again!
 
Can you explain the different ways to connect to a database?
faq333-178

has several examples... some are w/o DNS.
-Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top