Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 24th, 2005, 11:45 AM
Registered User
 
Join Date: May 2005
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!


 
Old May 24th, 2005, 11:30 PM
Friend of Wrox
 
Join Date: Jun 2003
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
 
Old May 25th, 2005, 11:03 AM
Registered User
 
Join Date: May 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks I didn't even realize that!






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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.