ASP.NET Help!!!!!

  CutNpaste 17:02 26 Nov 04


could someone give me a script for inserting a record into an access database using C#, it would be grateful.

Also if possible, to delete a record.


  Taran 17:35 26 Nov 04

You need several things to be able to do what you want, which include establishing a connection from the web page to the database, using the names of the record sets or database field names to query the information in it, a good overall understanding of databases, their design and data normalisation, among other things.

A query can read from, write to or remove information in a database.

A query is a series of statements in SQL.

SQL is, to most people, Structured Query Language, although that isn't strictly the correct interpretation of the acronym, let's not split hairs, so for now we'll settle on it standing for Structured Query Language.

A simple query could be like this:


Note that the query ends with a semi-colon.

The above query, when broken into its component parts, does this:

SELECT* says that you want to Select (view) all (*)

FROM FRIENDS means that the database table you want to look in is called FRIENDS

WHERE LAST_NAME = "Smith"; is asking for any records with a last name of Smith

The whole thing reads, more or less, Select all records from table name friends where the last name is Smith. Simple really, once you have a handle on some basics.

To start with, I'd suggest you do some reading on the whole subject and since you've asked about ASP.NET I strongly suggest you try the Microsoft .NET site at click here - it is stuffed to the gills with loads of tutorials, a nice, free .NET editor, some sample applications to show you how things work, and all kinds of other things.

A kick-starter on SQL can be found click here

There is no way to post working code without knowing what your database is, its name, the tables in it and the record field names in the tables, along with a couple of other things which would be handy to know.

Post again with the code you have and some details of your database and one of us will walk you through things.


  CutNpaste 23:24 27 Nov 04

Basically i am making a simple blog system. The the database contains one table with, ID, Name,Email and blog as the feilds and id as the primary key. The following code shows whats in my database but u want to be able to insert a records inside. Thanks for the links, i'll try them out.

<%@ Import Namespace="System.Data.OleDb" %>

<script runat="server">
sub Page_Load
dim dbconn,sql,dbcomm,dbread
dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & server.mappath("blog.mdb"))
sql="SELECT * FROM blog"
dbcomm=New OleDbCommand(sql,dbconn)
end sub


<form runat="server">
<asp:Repeater id="blog" runat="server">

<table border="1" width="100%">
<tr bgcolor="#b0c4de">

<tr bgcolor="#f0f0f0">
<td><%#Container.DataItem("name")%> </td>
<td><%#Container.DataItem("email")%> </td>
<td><%#Container.DataItem("blog")%> </td>
<td> </td>




  CutNpaste 23:33 27 Nov 04

By the way i dont know wheher its c# or vb but i'm suppose to use c#.
Dont blame me for not knowing much, as we only just learned about databases and And we havent been taught well enough in the lectures and they expectus to create a blog system with users logging in and adding and deleting blogs etc. They say "learn from the web", but my point was why dont they teach and show us the basics of how to connect (they did), how to insert data and how to delete. And as a bonus if they taught us about cookies and sessions it would have been helpful. From what we were been told, was that is the latest technology and is also a completely new language as many asp scripts dont run with

Any way thanks for your help

  Taran 01:28 30 Nov 04

I've been away for a few days break over the weekend, so this is the first chance I've had to look back to this thread.

Without wanting to appear churlish, if you have an assignment to complete, asking for a ready made script from one of us is hardly going to teach you very much.

If you feel that your lecturers were not as helpful as they might have been, that is an issue you should pursue, but through the proper channels and before you start kicking up any sort of a fuss you should go back to said tutors and start asking questions. Ask lots of them and make sure you understand the answers you get.

ASP and ASP.NET have some common ground but it is correct that standard ASP scripts often will not run in a .NET environment. The whole world of .NET is a far cry from standard ASP programming, although familiarity of one will certainly help when working with the other.

Many colleges and universities teach basic principles and then expect students to advance their own skills through a process of research and practice. When I say "basic principles" you can have them at any level - there are basic principles of programming at beginner, intermediate and advanced levels, so don't confuse the term "basic principles" as being purely for a beginner to the topic. Specific questions or problems with a lecturer or their teaching may be addressed at future lectures if need be, but this is a common teaching method that works well.

If you knew what was involved in cookies and sessions, perhaps it would be more obvious why these topics were not covered. Both are quite involved and reasonably advanced: neither are suitable material for students who are not fully familiar with inserting and deleting data. Attempting to teach those more complex concepts when the basics are lacking is a real 'cart before the horse' scenario.

There are loads of online resources to learn web programming in any language, and a few good books are available on the subject too.

If you have a specific question I am prepared to consider answering it, but I draw the line at offering an off the peg solution to a school, college or university assignment. I'd be very upset with my students if they tried a similar approach. A script supplied by me (or anyone else) will not help you understand what it is you are doing and so you gain nothing but a meaningless solution, which kind of defeats the object of a further education course to begin with.

  CutNpaste 13:39 30 Nov 04

Your right in saying what u said. I'll make some effort of learning the relevant stuff on my own.
By the way i have one more question. Can u embedd html tags in the mailer function in php.


  Taran 01:49 01 Dec 04

Can you confirm whether you mean the PHP mail() function or the popular PHPMailer script from Sourceforge click here

The online PHP manual click here has all the documentation for all of your PHP project needs, and this link click here covers the mail() function in greater detail.

The way PHP, ASP and other dynamic languages work is that the server processes the code and outputs HTML to the web browser.

You can have something like this in a PHP web page:



perform some clever server side tricks








do some more clever PHP stuff



Then do even more PHP





The site visitor will see a graphical version of this:






Lots of page content



So the idea is that the web server can tell that there is PHP code to read by the fact that your web page ends with .php or one of the variations of that suffix. Some people use .php4 or .phtml but I see little reason in most cases to deviate from .php

As long as your web page is called something like pagename.php the web server reads the PHP code in the page and does whatever the code tells the server to do. The results are output to the web browser and, as you can see from the above code example, they could be part of a document header or the body content of the page.

PHP can send HTTP headers, so you might have some PHP code at the top of a page, above your HTML which can be used to set cookies, manage authentication, redirect users and a few other nice things.

And just like the above example, the mail() function in PHP is often used along the lines of:


/* recipients */

$to = "[email protected]" . ", " ;
$to .= "[email protected]";

/* subject */

$subject = "Christmas is coming";

/* message */

$message = '



<title>Christmas is coming</title>


<p>Santa is on his way !</p>

Tons of other HTML code goes in here...




$headers = "MIME-Version: 1.0\r\n";

$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

$headers .= "To: CutNpaste <[email protected]>, Taran <[email protected]>\r\n";

$headers .= "From: Christmas is coming

<[email protected]>\r\n";

$headers .= "Cc: [email protected]\r\n";

$headers .= "Bcc: [email protected]\r\n";

mail($to, $subject, $message, $headers);


  Taran 01:52 01 Dec 04

I meant to add that you will see from the last example how PHP and HTML code can interact, but without a bit of detail from you I'm not sure exactly what you mean by "embedd html tags in the mailer function..."

Perhaps I've answered it for you or not, as the case may be.

  CutNpaste 15:15 01 Dec 04

The last example is the one i want. Thats cool, so this means i can format the html as i want it and the person recieving the email will see a formatted email. RIGHT or WORNG let me know.

Thanks for ur help TARAN

  Taran 00:50 02 Dec 04

You can choose the options of the email in terms of formatting, using any of the standard tagged page structures.

Be advised that most corporates disallow HTML email for a variety of very good reasons, so HTML email has some inherent limitations from the outset, depending on where and how you want to use it of course.

  CutNpaste 01:04 02 Dec 04

When printing a html page he url gets printed on the bottom and the title on top. Is there a way or script that would hide the url an title, so that only the contents can be printed off.

I wold really appreaciate a response on this one .


This thread is now locked and can not be replied to.

Samsung Galaxy S8 review

1995-2015: How technology has changed the world in 20 years

What’s happening in VR right now: From psychedelic art to combat therapy

Siri not working? Try these troubleshooting fixes