| re: Inserting data into a table
You forgot to reference the actual data itself
INSERT INTO tbltest (username, password, category)
VALUES (' " & u & " ',' " & p & " ',' " & c & " ')
note use of single quotes to delimit the text fields - I have put extra
space between single and double quote to be clear - you should remove other
wise your stored data will have leading and trailing space
"Geoff Wickens" <gwickens@hotmail.com> wrote in message
news:NSk2b.142$xA3.12@newsfep1-gui.server.ntli.net...[color=blue]
> I am quite new to all this but am trying to create a database driven site.[/color]
I[color=blue]
> have been able to use information from my sample database but I now want[/color]
to[color=blue]
> be able to insert data into it. At present I put the data into my local[/color]
copy[color=blue]
> of the access database and then upload it again to my server - not an[/color]
ideal[color=blue]
> solution!
>
> I have tried using the INSERT command and it works fine if I enter the[/color]
data[color=blue]
> into the statement. What I really want to do is collect the data from a[/color]
form[color=blue]
> and then insert this into the database. My code is as follows:
>
> Page for collecting the data:
>
> <form name="useradd" method="post" action="testadd.asp">
> <p>Username:
> <input type="text" name="username">
> </p>
> <p>Password:
> <input type="text" name="password">
> </p>
> <p> Category:
> <select name="select">
> <option>member</option>
> <option>committee</option>
> <option>admin</option>
> <option>guest</option>
> </select>
> </p>
> <p>
> <input type="submit" name="Submit" value="Submit">
> <input type="reset" name="Reset" value="Reset">
> </p>
> </form>
>
>
> I then have the following code on the page (testadd.asp) to add this
> information to my database.
>
> <%
> u = Request.Form("username")
> p = Request.Form("password")
> c = Request.Form("category")
>
> Set Catalog=Server.CreateObject("ADODB.Recordset")
> Catalog.open "INSERT INTO tbltest (username, password, category) VALUES (u[/color]
,[color=blue]
> p, c)", "DSN=members"
> %>
>
> The thing which goes wrong is the VALUES part of the statement. It seems[/color]
to[color=blue]
> want 'u' etc but then puts in this text rather than the contents of my
> variable.
>
> Any help most welcome.
>
> Geoff Wickens
>
>[/color] |