•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 403,519 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,807 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 659 | Replies: 4
![]() |
•
•
Join Date: Jun 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
I am trying to connect my login page to an access database. Right now I am simply storing the values inside the database .I am having trouble connecting to the databse itself. Below is the code that I have written using VBScript. What am I doing wrong? ...Thanks in advance
asp Syntax (Toggle Plain Text)
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <%@ language="vbscript" %> <% sub B3_onclick() Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="C:\Documents and Settings\sridhanj\Desktop\project\logon.mdb" SQL = "INSERT INTO tblusers ('UID') VALUES (document.loginform.T2.value);" Conn.Execute(SQL) Conn.Close end sub %> <title>New Page 1</title> </head> <body> <form name = "loginform"> <h1 align="center">LOGIN</h1> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center"> </p> <p align="center">Username: <input type="text" name="T1" size="20"> </p> <p align="center">Password: <input type="password" name="T2" size="20" maxlength="12"> </p> <p align="center"> </p> <p align="center"><input type="submit" value="Submit" name="B3"> <input type="reset" value="Reset" name="B4"></p> </form> </body> </html>
Last edited by peter_budo : Jul 7th, 2008 at 7:22 am. Reason: Code tag correction, tags are [code]&[/code] not <code>with</code>
•
•
Join Date: Jul 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Well what i suggest is that u comment ur code where ur closing ur connection and then try if that works or not
like this
'Connection.close
try this
Another thing is that try saving your database to somewhere else
like in C Drive and then use the correct path
another option is that u can create a DSN and then open the connection rather than using a DSN Less connection what ur doing here
hope u know how to do that you need to go to control panel > Administrative tools > ODBC then select the SYstem DSN tab and then select ADD on the right side then a message box will appear saying Select a driver for which u want to setup the data source - then in the NAME select Microsoft driver (*.mdb) then Type ur DSN Name here and select the database that is locate ur DB where it is located in the Computer System for example ur DB is in C:/ProjectsDB so u just browse and locate it here ok and then press ok
then in VB script
ur codewill look like this if u want to use a DSN Connection
for example
set mycon = Server.CreateObject("ADODB.Connection")
myDSN = " " here ull put ur Database DSN which u will make
then simply open ur dsn and con
myCon.open myDSN
and then u can execute ur query
like
like this
'Connection.close
try this
Another thing is that try saving your database to somewhere else
like in C Drive and then use the correct path
another option is that u can create a DSN and then open the connection rather than using a DSN Less connection what ur doing here
hope u know how to do that you need to go to control panel > Administrative tools > ODBC then select the SYstem DSN tab and then select ADD on the right side then a message box will appear saying Select a driver for which u want to setup the data source - then in the NAME select Microsoft driver (*.mdb) then Type ur DSN Name here and select the database that is locate ur DB where it is located in the Computer System for example ur DB is in C:/ProjectsDB so u just browse and locate it here ok and then press ok
then in VB script
ur codewill look like this if u want to use a DSN Connection
for example
set mycon = Server.CreateObject("ADODB.Connection")
myDSN = " " here ull put ur Database DSN which u will make
then simply open ur dsn and con
myCon.open myDSN
and then u can execute ur query
like
Hi,
I found two things in your code that, I think are causing problem.
1. b3_onclick: events are not called like this in asp.
Moreever, what you are trying to do is clicking on submit Button will make you conect to database and then execute something, right?
What you have written is a VB code where everyting is on client side. but here in ASP things are not like VB.
you will first need to do something.
Put your code and mdb file in inetpub/wwwroot folder. then use the following code
also the form should be defind as
I found two things in your code that, I think are causing problem.
1. b3_onclick: events are not called like this in asp.
Moreever, what you are trying to do is clicking on submit Button will make you conect to database and then execute something, right?
What you have written is a VB code where everyting is on client side. but here in ASP things are not like VB.
you will first need to do something.
Put your code and mdb file in inetpub/wwwroot folder. then use the following code
<%
if request.servervariables("HTTP_METHOD") = "POST" then
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&server.mappath("logon.mdb")
SQL = "INSERT INTO tblusers ('UID') VALUES ("&request.form("T1")&");"
Conn.Execute(SQL)
Conn.Close
end if
%>also the form should be defind as
<form method=post name = "loginform" action="">
Vivek Rawat
Keep solving complexities.
Keep solving complexities.
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
access amd avatar backup blue gene breach business chips daniweb data data protection database development dos energy enterprise europe government hacker hardware hp ibm ibm. news ip it linux medicine memory microshaft microsoft ms news open source openoffice pc ps3 red hat russia security server sql sun supercomputer supercomputing survey trends ubuntu web working x86
- Updated : Simple ASP.Net Login Page (ASP.NET)
- memory management in wndows 2000 (Windows NT / 2000 / XP / 2003)
- Crystal Report Design!!!!! (VB.NET)
- connection from 3 location? (VB.NET)
Other Threads in the ASP Forum
- Previous Thread: Which part of this code is the Input Box?
- Next Thread: Any Tools are available


Linear Mode