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.



 Subscribe in a reader

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

Notices


Closed Thread
 
LinkBack Thread Tools
  #1  
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
adding to database

can someone tell me (in simple terms!!) how to add a password (pwd) and a username (uid) to a database?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!

  #2  
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')")
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #3  
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
thanks... is that it?! seems so simple...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #4  
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
it says:

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


any ideas?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #5  
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #6  
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #7  
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
it is, i put the exact code you showed me... but it doesn't like it for some reason...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #8  
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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #9  
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
will do as soon as I get home!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #10  
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
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #11  
Old Aug 16th, 2004, 19:11
Rob's Avatar
Rob Rob is offline
Webforumz Founder
Join Date: Jul 2003
Location: Southern UK
Age: 34
Posts: 3,159
Blog Entries: 7
Thanks: 27
Thanked 19 Times in 16 Posts
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
__________________
Click the 'Thanks!' button if this post has helped you

Rob - Webforumz Founder
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #12  
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
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?!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #13  
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!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #14  
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
nothings working... all the values ARE there
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #15  
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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #16  
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
yea it looks as it should
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #17  
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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #18  
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
same one...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
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 21:29.


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