Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 24th, 2005, 11:45 AM
Registered User
 
Join Date: May 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default writing to a ms access database

I am having trouble writing the data from my web form to the ms access database I created.

Here is the code I have:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim MySQL As String = "Insert into Table1 (ID, FName, LName) values(@ID, @Fname, @Lname)"

Dim myConn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source= C:\Inetpub\wwwroot\db1.mdb")

Dim Cmd As New OleDbCommand(MySQL, myConn)
Cmd.Parameters.Add(New OleDbParameter("@ID", txtID.Text))
Cmd.Parameters.Add(New OleDbParameter("@Fname", txtFName.Text))
Cmd.Parameters.Add(New OleDbParameter("@Lname", txtLName.Text))
myConn.Open()
Cmd.ExecuteNonQuery()
myConn.Close()
BindData()
End Sub

Sub BindData()
Dim MySQL As String = "Select * from Table1"
Dim myConn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source= C:\Inetpub\wwwroot\db1.mdb")
Dim ds As DataSet = New DataSet
Dim Cmd As New OleDbDataAdapter(MySQL, myConn)
Cmd.Fill(ds, "Table1")
myConn.Close()
End Sub

Here is the error that I get:

Operation must use an updateable query.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Operation must use an updateable query.

Source Error:

Line 95: myConn.Open()
Line 96: Cmd.ExecuteNonQuery()
Line 97: myConn.Close()

Source File: c:\inetpub\wwwroot\Test1\WebForm1.aspx.vb Line: 96

Please Help!


Reply With Quote
  #2 (permalink)  
Old May 24th, 2005, 11:30 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Looks like you chosen to post that under ASP forum, try posting that under any of the .NET forums here.

Cheers

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
  #3 (permalink)  
Old May 25th, 2005, 11:03 AM
Registered User
 
Join Date: May 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks I didn't even realize that!

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble writing to an Access Database JAdkins Classic ASP Basics 5 June 27th, 2007 03:05 PM
Database migration MS Access 2003 to MS SQL 2000 ayazhoda SQL Server 2000 3 April 23rd, 2007 11:38 AM
writing SQL queries in MS access,VBA NovieProgrammer Access VBA 2 April 2nd, 2005 07:15 PM
Writing to access database from asp.et RaZorCleaN Access 2 October 9th, 2003 01:16 PM



All times are GMT -4. The time now is 02:03 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.