Jump to content

Anyone with experience in Vb script and asp please help


andy_watson00

Recommended Posts

ok im doing a website for one of my university projects and it has to be a web log.

 

 

 

 

 

 

 

So one of the main things I want to be able to do is produce a list of logs showing maybe a subject author and date, and allow the user to click on one of these to go to a page with the actual text of the log, sort of like what happens on this website. I am really having trouble finding a way to do this so anyone who can at all or even offer code samples please help. Also I am aware this isnÃÆââââ¬Å¡Ã¬Ã¢ââ¬Å¾Ã¢t the best forum to post this on, but im just running out of options

Link to comment
Share on other sites

Will you be able to use a Database system like MC Access or SQL Server (if available) for this project? Or is the web log data required to be stored in a flat text file, or another format?

 

 

 

 

 

 

 

If you know the answer to the above I can help you write the code! :)

Link to comment
Share on other sites

im using an MS access dtabase to store al the info i need

 

 

 

 

 

 

 

Right, since this is for a university thing, I take it you know how to use ADO and manipulate the database. Right?

Link to comment
Share on other sites

Ok firstly, I won't do the assignment for you but theres nothing wrong with a bit of direction. Since your a student at University I don't see why you can't find out the code specifics yourself. I'm going to offer help with building an ASP and MS Access driven script, I'll be pretty high level. When it comes to the structure, layout and process of this script you will probably want to go with something like the following:

 

 

 

 

 

 

 

The Database

 

 

 

Ok, starting from the ground up. You should only need 1 Table for this application. In this table, as you have already pointed out, you will have 5 columns. An ID column of type unique identifier, and 4 other columns, the Subject, Author, Date and log content. The last 4 will be of type Text, except the Date column, this should be type Date (format XX/XX/XXXX).

 

 

 

 

 

 

 

From here you can manually enter in a few test entry's to get started. That looks like basically it for the database for now.

 

 

 

 

 

 

 

Index Page - index.asp

 

 

 

Here is where the web log summary's will be displayed. You just need a simple ASP document, with HTML tables in it. Organise the tables how you want the data to be displayed then we'll look at what needs to be done for getting the database data into the ASP file.

 

 

 

 

 

 

 

Ok you will need 1 database connection object and 1 Recordset. If you aren't sure how to define these and open/close them then I suggest you talk to your teacher or visit http://www.w3schools.com. You said you understand ADO so you should be able to get on with a start.

 

 

 

 

 

 

 

The database connection should just open the MS Access file for reading and then you can go ahead and create a Recordset. With this Recordset you will only need to query it with 1 SQL query. The query will probably need to look something like this:

 

 

 

 

 

 

 

sql = "SELECT * FROM TableName"

 

 

 

So you have your web log's and other needed information stored in the Recordset now, now lets write it to the screen. You know your Response.Write commands, referenece the w3schools website if you do not, so go ahead and write out the details as you want them displayed on the screen. This part of your script may look something like this:

 

 

 

 

 

 

 

</pre><table>



  Subject







  Date







  Author







"><%=rs("Subject")%>







  <%=rs("Date")%>







  <%=rs("Author")%>



</

 

 

 

Again, a very high level view of the code, ask your teacher or reference the above website if you need help with the actual coding of it.

 

 

 

 

 

 

 

So that will display all the current entries in the database. Now you want to be able to dig into the entry and view its content. this is why there is a link added onto the Subject of the entry. This links to a new page, which carries over the ID of the row you want.

 

 

 

 

 

 

 

The Viewing Page - view.asp

 

 

 

At the top of this page you would need to grab the value of the ID field from the query string with the following code:

 

 

 

 

 

 

 

<%



dim id



id = Request.QueryString("id")



%>

 

 

 

Then on this page you will need to create another database connection and recordset. This time the SQL query would look something more like:

 

 

 

 

 

 

 

sql = "SELECT * FROM TableName WHERE ID=" & id

 

 

 

The "id" text in the above query will tell the recordset to only return the results for the wanted web log.

 

 

 

 

 

 

 

Then the rest of the view.asp page might look something like this:

 

 

 

 

 

 

 

</pre><table>



  Subject







  <%=rs("Subject")%>







  Date







  <%=rs("Date")%>







  Author







  <%=rs("Author")%>







  Web Log







  <%=rs("Content")%>



</

 

 

 

Ok I think that'll do for now, don't hesitate to ask questions about the above code and processes if you do not understand. I have not tested any of the above code, I've written what I think will work and how the application should be put together. Please rewrite the script from scratch using the idea and structure above, copy and pasting this code will just give you hell because it is no where near finished.

 

 

 

 

 

 

 

Another thing we haven't covered is the actual input of the Web log's themself. Instead of having to manually add them into the MS Access database you could setup another page, add.asp for example, and create the neccessary HTML form, and database INSERT INTO commands to make this page. This is something that you may want to try implementing yourself after you've completed the initial task, extra marks never hurt anyone :P

 

 

 

 

 

 

 

Please remember that I have explained this process in very little detail, keeping it high level so I'm not acually doing your assignment for you, just giving you a push into the right directly :) Good luck mate and please feel free to ask anymore questions here!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.