Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > adding to db

Reply
Thread Tools

adding to db

 
 
mike
Guest
Posts: n/a
 
      07-02-2003
I bought 3 books and spent weeks trying to add a record to
my database, but haven't figured it out??? I've tried both
sql and addnew method, but to no avail. Below is my sql
method. Any ideas would be highly appreciative.

<% @Language=VBScript %>
<% Option Explicit %>
<% Response.Expires = 0 %>
<%
Dim objConn, objRS, strQ
set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString="DRIVER={Microsoft Access Driver
(*.mdb)};" & _

"DBQ=c:\home\mike\www\data\data.mdb"
objConn.Open
strQ = "INSERT INTO appointments (name) VALUES ('mike')"
objConn.Execute strQ
set objRS = objConn.Execute("SELECT * FROM appointments")
%>
<html>
<body>
<%
objRS.Close : objConn.close
Set objRS = Nothing : set objConn = Nothing
%>
</body>
</html>
 
Reply With Quote
 
 
 
 
Tom B
Guest
Posts: n/a
 
      07-02-2003
I'd use a different connection string.
objConn.ConnectionString="Provider=Microsoft.Jet.O LEDB.4.0;Data
Source=C:\home\mike\www\data\data.mdb;"

see www.connectionstrings.com


I assume your database has a table called appointments with a field called
name in it.
try
strQ="INSERT INTO appointments([name]) VALUES('mike')"
as I'm sure name is a reserved word

move your "set objRS=" to ....
<html>
<body>
<%
Set objRS=objConn.Execute("SELECT [name] FROM appointments")
Do While not objRS.EOF
Response.Write "<LI>" & objRS.Fields("name").value & "</LI>" &
vbCrLF 'note no [ ] here
objRS.MoveNext
Loop
Set objRS=nothing 'note you don't close the Recordset......because
you didn't open it.
objConn.Close
Set objCOnn=nothing
%>
</body>
</html>






"mike" <(E-Mail Removed)> wrote in message
news:03c101c340cc$d79c5a00$(E-Mail Removed)...
> I bought 3 books and spent weeks trying to add a record to
> my database, but haven't figured it out??? I've tried both
> sql and addnew method, but to no avail. Below is my sql
> method. Any ideas would be highly appreciative.
>
> <% @Language=VBScript %>
> <% Option Explicit %>
> <% Response.Expires = 0 %>
> <%
> Dim objConn, objRS, strQ
> set objConn = Server.CreateObject("ADODB.Connection")
> objConn.ConnectionString="DRIVER={Microsoft Access Driver
> (*.mdb)};" & _
>
> "DBQ=c:\home\mike\www\data\data.mdb"
> objConn.Open
> strQ = "INSERT INTO appointments (name) VALUES ('mike')"
> objConn.Execute strQ
> set objRS = objConn.Execute("SELECT * FROM appointments")
> %>
> <html>
> <body>
> <%
> objRS.Close : objConn.close
> Set objRS = Nothing : set objConn = Nothing
> %>
> </body>
> </html>



 
Reply With Quote
 
 
 
 
Robb Meade
Guest
Posts: n/a
 
      07-02-2003
"mike" wrote ...

> I bought 3 books and spent weeks trying to add a record to
> my database, but haven't figured it out??? I've tried both
> sql and addnew method, but to no avail. Below is my sql
> method. Any ideas would be highly appreciative.


[snip]

Getting any specific errors or is it returning a white page with no text but
yet not adding the data?

more info needed.

Regards

Robb


 
Reply With Quote
 
Bob Barrows
Guest
Posts: n/a
 
      07-03-2003
mike wrote:
> Thanks Tom, it was your suggestion to move code to the
> body that led me to find my error of a read only db. I
> don't have it read only, but never-the-less, my code only
> works with a new db. Thanks tremendously.


http://www.aspfaq.com/show.asp?id=2062 - updatable cursor
http://www.aspfaq.com/show.asp?id=2009 - 80004005 errors


 
Reply With Quote
 
 
 
Reply

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Question: Adding Wireless to a Hard-Wired Home Office (w/Web & Email) Nick Knight Wireless Networking 2 01-06-2005 03:46 AM
Adding an Antenna Pigtail to a WiFi card Guy Smith Wireless Networking 0 12-31-2004 11:15 AM
Adding Linksys or Dlink into a Microsoft networking product config =?Utf-8?B?c2tsZWZmbg==?= Wireless Networking 0 12-03-2004 04:12 PM
RE: Adding laptop to a new network =?Utf-8?B?TWFyayBQ?= Wireless Networking 0 10-20-2004 07:45 PM
Adding Wireless acess point to existing network. Shawn Wireless Networking 1 10-17-2004 03:53 PM



Advertisments