/    Sign up×
Community /Pin to ProfileBookmark

working with databases theory

I’m a little unsure about this. I’m not uber experienced with databases and I just want to make sure I at least understand the concept of what I’m doing.

So, here it goes. I have a database (it’s already been created curtesy of the government) and I’d like to able to allow my visitors to view the information in database. Bear with me, I’m a little hazy on this.

My question is, Can I create a form and whatever the user inputs would then become the “variables” (for lack of a better word) that I instuct the database to look for? I’m not sure that entirely makes sense, but if needed, I can try to clarigy it.

to post a comment
Full-stack Developer

8 Comments(s)

Copy linkTweet thisAlerts:
@NevermoreMay 15.2003 — That is possible. I can do it with PHP and MySQL, but for ASP, MSSQL etc. you would need someone else.
Copy linkTweet thisAlerts:
@firegryphon3207authorMay 15.2003 — Thanks. The Database itself is an Access database. I'm pretty green with the asp stuff here. I'm trying to figure out how to execute the idea of how I want this to work. Thanks for the help! Any other ideas are welcome.
Copy linkTweet thisAlerts:
@NevermoreMay 15.2003 — Your database will have to be converted to a web-ready format. What technologies does your server support?
Copy linkTweet thisAlerts:
@AdamGundryMay 15.2003 — You should be able to read an Access database in ASP. Find a tutorial on ASP/databases, and if you have any specific questions post in the ASP forum.

Adam
Copy linkTweet thisAlerts:
@firegryphon3207authorMay 15.2003 — That was my understanding as well. Since we don't use alot of server technologies across the site, I'm at this point really just determining what goes where. Which pages need what.

Any recomendations on a asp/datasbase tutorials? I've hit up w3cschools, any other suggestions?
Copy linkTweet thisAlerts:
@AdamGundryMay 15.2003 — I use PHP and MySQL so I can't really advise you on ASP tutorials. You could try posting a question in the ASP forum.

Adam
Copy linkTweet thisAlerts:
@firegryphon3207authorMay 15.2003 — Thanks for the help-I'm going to take the advice because after surfing around I'm even more confused than when I started.
Copy linkTweet thisAlerts:
@khakiMay 16.2003 — hi firegryphon3207...

I don't know if this will confuse you even more...

or maybe less :rolleyes:

but anyway... here is a working page that only requires you to plug-in your own Variable name, DB name, Table name, and Field names.

(the areas that you need to "plug-in" are in [B]bold[/B])

You will also need to create the page that calls this one (the one that submits the user's form input).

give this a go and let me know if you can get it to work for you.

have fun ?

? k

[SIZE=1]

<%

' this part retrieves the users input from the form and assigns a variable to hold that value



dim [B]passed_variable[/B]

[B]passed_variable[/B] = Request.Form("[B]user_input_from_form[/B]")

%>



<%

' this connection code is styled similarly to the ones used on asp.com (i think).



openStr = "driver={Microsoft Access Driver (*.mdb)};" & _

"dbq=" & Server.MapPath("[B]put_the_name_of_your_database_here.mdb[/B]")

Set cn = Server.CreateObject("ADODB.Connection")

cn.Open openStr



' now you need to query the database using SQL and insert the variable as a search criteria.

' (note that there is an ORDER BY used here. that would only really apply to queries that...

' ... return more than 1 record. just so you know)



sql = "SELECT [B]name_of_field_1, name_of_field_2, name_of_field_3[/B] " & _

"FROM [B]name_of_the_table[/B] " & _



"WHERE ([B]name_of_field_1[/B] = '" & [B]passed_variable[/B] & "')" & _


"ORDER BY [B]name_of_field_1[/B];"



Set rs = Server.CreateObject("ADODB.Recordset")

rs.Open sql, cn, 3, 3

%>



<html>

<head>

<title></title>

</head>

<body>



<!-- this part creates a table that is filled with the returned values of the database query -->

<!-- if the query is based on a unique value (returns only 1 record), this table will work for that -->



<table border="1">

<tr>

<td><b>field_1 Heading</b></td>

<td><b>field_2 Heading</b></td>

<td><b>field_3 Heading</b></td>

</tr>

<tr>

<td><% = rs.Fields("[B]name_of_field_1[/B]") %></td>

<td><% = rs.Fields("[B]name_of_field_2[/B]") %></td>

<td><% = rs.Fields("[B]name_of_field_3[/B]") %></td>

</tr>

</table>



<br>

<!-- if the query results will return more than 1 record, this table will work for that -->

<!-- (although you should realize that this table can also be used to return a single record as well) -->

<br>



<table border="1">

<tr>

<td><b>field_1 Heading</b></td>

<td><b>field_2 Heading</b></td>

<td><b>field_3 Heading</b></td>

</tr>

<%

Do While Not rs.EOF

%>

<tr>

<td><% = rs.Fields("[B]name_of_field_1[/B]") %></td>

<td><% = rs.Fields("[B]name_of_field_2[/B]") %></td>

<td><% = rs.Fields("[B]name_of_field_3[/B]") %></td>

</tr>

<%

rs.MoveNext

Loop

%>

</table>

<%

' this part shuts it all down (regardless of which table you use)



rs.Close

Set rs = Nothing

cn.Close

Set cn = Nothing

%>



</body>

</html>

[/SIZE]
×

Success!

Help @firegryphon3207 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...