adding to database

This is a discussion on "adding to database" within the Classic ASP section. This forum, and the thread "adding to database are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Aug 13th, 2004, 08:44
benbacardi's Avatar
Highly Reputable Member
Join Date: Feb 2004
Location: United Kingdom
Age: 20
Posts: 611
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to benbacardi Send a message via Skype™ to benbacardi
adding to database

can someone tell me (in simple terms!!) how to add a password (pwd) and a username (uid) to a database?

  #2 (permalink)  
Old Aug 13th, 2004, 11:16
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
Set objRS = objConn.Execute("INSERT INTO table (username,password) VALUES ('admin','secret')")
  #3 (permalink)  
Old Aug 13th, 2004, 15:47
benbacardi's Avatar
Highly Reputable Member
Join Date: Feb 2004
Location: United Kingdom
Age: 20
Posts: 611
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to benbacardi Send a message via Skype™ to benbacardi
thanks... is that it?! seems so simple...
  #4 (permalink)  
Old Aug 13th, 2004, 15:59
benbacardi's Avatar
Highly Reputable Member
Join Date: Feb 2004
Location: United Kingdom
Age: 20
Posts: 611
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to benbacardi Send a message via Skype™ to benbacardi
it says:

Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: 'objConn'
/login/slog/regcheck.asp, line 56


any ideas?
  #5 (permalink)  
Old Aug 16th, 2004, 08:21
New Member
Join Date: Jul 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
there is a tutorial at www.webthang.co.uk, (select dreamweaver tutorials) the tutorials here are really easy to follow step by step, the way I need them.
  #6 (permalink)  
Old Aug 16th, 2004, 08:33
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
objConn should be the name of your connection object.
  #7 (permalink)  
Old Aug 16th, 2004, 11:32
benbacardi's Avatar
Highly Reputable Member
Join Date: Feb 2004
Location: United Kingdom
Age: 20
Posts: 611
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to benbacardi Send a message via Skype™ to benbacardi
it is, i put the exact code you showed me... but it doesn't like it for some reason...
  #8 (permalink)  
Old Aug 16th, 2004, 11:55
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
can you post the code for your asp page so i can take a look?
  #9 (permalink)  
Old Aug 16th, 2004, 12:04
benbacardi's Avatar
Highly Reputable Member
Join Date: Feb 2004
Location: United Kingdom
Age: 20
Posts: 611
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to benbacardi Send a message via Skype™ to benbacardi
will do as soon as I get home!
  #10 (permalink)  
Old Aug 16th, 2004, 17:37
benbacardi's Avatar
Highly Reputable Member
Join Date: Feb 2004
Location: United Kingdom
Age: 20
Posts: 611
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to benbacardi Send a message via Skype™ to benbacardi
heres the code: index.asp posts the data to check.asp:

check.asp:
Code: Select all
<%
'here is the connection string
Set conn = server.createobject("adodb.connection")
'this connection uses JET 4 it is the prefered method of connecting to an access database
DSNtemp = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("login.mdb")
'if you cant use JET then comment out the line above and uncomment the line below
'DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.Mappath("/slog/login.mdb")
conn.Open DSNtemp

'here we are getting the info from the login form
If InStr(Request.Form("uid"),"'") Then
uid = Replace(Request.Form("uid"),"'"," ")
Else
uid = Request.Form("uid")
End If
If InStr(Request.Form("pwd"),"'") Then
pwd = Replace(Request.Form("pwd"),"'"," ")
Else
pwd = Request.Form("pwd")
End If
If InStr(Request.Form("pwd2"),"'") Then
pwd2 = Replace(Request.Form("pwd2"),"'"," ")
Else
pwd2 = Request.Form("pwd2")
End If

If uid = "" or pwd = "" or pwd2 = "" Then
response.redirect("all.asp")
end if

'now we will querry the database for a match
SQL = "Select * From users Where uid = '" & uid & "' And pwd = '" & pwd & "'"
Set RS = Conn.Execute(SQL)

'if the user is found we will redirect the user to the already found username page
If Not RS.EOF Then
 response.redirect("used.asp")
	
	'always always always destroy recordsets and close connections!
	Set RS = Nothing
	Conn.Close


Else

if pwd = pwd2 then


Set objRS = objConn.Execute("INSERT INTO users (uid,pwd) VALUES (uid,pwd)"
)
response.redirect("welcome.asp") 
Set objRS = Nothing
objConn.Close

else
response.redirect("checkpwd.asp")
end if
 
   
   	'AGAIN always always always destroy recordsets and close connections!
	Set RS = Nothing
	Conn.Close
  
End If
%>
thanks
  #11 (permalink)  
Old Aug 16th, 2004, 19:11
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
Change this code:-
Code: Select all
Set objRS = objConn.Execute("INSERT INTO users (uid,pwd) VALUES (uid,pwd)"
)
response.redirect("welcome.asp") 
Set objRS = Nothing
objConn.Close
to this:-
Code: Select all
Set objRS = Conn.Execute("INSERT INTO users (uid,pwd) VALUES (uid,pwd)"
)
response.redirect("welcome.asp") 
Set objRS = Nothing
objConn.Close
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
  #12 (permalink)  
Old Aug 16th, 2004, 19:55
benbacardi's Avatar
Highly Reputable Member
Join Date: Feb 2004
Location: United Kingdom
Age: 20
Posts: 611
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to benbacardi Send a message via Skype™ to benbacardi
i get this problem now...

check.asp:
Code: Select all
<%
'here is the connection string
Set conn = server.createobject("adodb.connection")
'this connection uses JET 4 it is the prefered method of connecting to an access database
DSNtemp = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("login.mdb")
'if you cant use JET then comment out the line above and uncomment the line below
'DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.Mappath("/slog/login.mdb")
conn.Open DSNtemp

'here we are getting the info from the login form
If InStr(Request.Form("uid"),"'") Then
user = Replace(Request.Form("uid"),"'"," ")
Else
user = Request.Form("uid")
End If
If InStr(Request.Form("pwd"),"'") Then
pword = Replace(Request.Form("pwd"),"'"," ")
Else
pword = Request.Form("pwd")
End If
If InStr(Request.Form("pwd2"),"'") Then
pword2 = Replace(Request.Form("pwd2"),"'"," ")
Else
pword2 = Request.Form("pwd2")
End If

If user = "" or pword = "" or pword2 = "" Then
response.redirect("all.asp")
end if

'now we will querry the database for a match
SQL = "Select * From users Where uid = '" & user & "' And pwd = '" & pword & "'"
Set RS = Conn.Execute(SQL)

'if the user is found we will redirect the user to the already found username page
If Not RS.EOF Then
 response.redirect("used.asp")
	
	'always always always destroy recordsets and close connections!
	Set RS = Nothing
	Conn.Close


Else

if pword = pword2 then

Set objRS = Conn.Execute("INSERT INTO users (uid,pwd) VALUES (user,pword)")
response.redirect("welcome.asp") 
Set objRS = Nothing
objConn.Close

else
response.redirect("checkpwd.asp")
end if
 
   
   	'AGAIN always always always destroy recordsets and close connections!
	Set RS = Nothing
	Conn.Close
  
End If
%>
error:

Error Type:
Microsoft JET Database Engine (0x80040E10)
No value given for one or more required parameters.
/login/slog/regcheck.asp, line 48

ideas?!
  #13 (permalink)  
Old Aug 17th, 2004, 08:07
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
Ben, A good way to find out which parameter is missing (or is incorrect) is to write out the SQL query to the screen, like this:

Code: Select all
SQL = "Select * From users Where uid = '" & user & "' And pwd = '" & pword & "'"
Response.Write SQL
Set RS = Conn.Execute(SQL)
That will show you the actual query that is being send to MS Acces. If you cant see the problem from that, then open up Access, click on the Queries tab, create and new query, in the top left, select SQL instead of design view, paste in the query which you have Response.Write to the screen, and click the execute button, Access should then prompt you for the missing parameter or highlight the problem for.

Hope that helps!
  #14 (permalink)  
Old Aug 17th, 2004, 18:55
benbacardi's Avatar
Highly Reputable Member
Join Date: Feb 2004
Location: United Kingdom
Age: 20
Posts: 611
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to benbacardi Send a message via Skype™ to benbacardi
nothings working... all the values ARE there
  #15 (permalink)  
Old Aug 18th, 2004, 08:22
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
So when you response.write SQL it looks fine?
  #16 (permalink)  
Old Aug 18th, 2004, 11:36
benbacardi's Avatar
Highly Reputable Member
Join Date: Feb 2004
Location: United Kingdom
Age: 20
Posts: 611
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to benbacardi Send a message via Skype™ to benbacardi
yea it looks as it should
  #17 (permalink)  
Old Aug 18th, 2004, 12:04
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
and what error message are you getting now?
  #18 (permalink)  
Old Aug 18th, 2004, 12:28
benbacardi's Avatar
Highly Reputable Member
Join Date: Feb 2004
Location: United Kingdom
Age: 20
Posts: 611
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to benbacardi Send a message via Skype™ to benbacardi
same one...
Closed Thread

Tags
adding, database

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a new page crackafaza PHP Forum 7 Feb 8th, 2008 22:08
Adding quizzes hawashp Web Page Design 12 Oct 5th, 2007 12:04
Adding a calendar? Stefan83 Website Planning 1 May 8th, 2007 19:18
XML Code for transfering data from one SQL Server Database to another database plolla Other Programming Languages 1 Aug 3rd, 2006 18:37
Adding RETURN line breaks to a database Lizard- Classic ASP 2 Aug 19th, 2004 09:49


All times are GMT. The time now is 15:39.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43