473,395 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Web Matrix guide tour: INSERT in Access table fails

Hi

I followed the Web Matrix guided tour and came to the "ASP.NET Pages with
Data
(Microsoft Access)" part.

There is really not much you can do wrong there, but for some reason, the
INSERT part gives me an error. Here is the function that fails (appart from
the exception handling everything is generated by the code wizard):

Function InsertManufacturer(ByVal manufacturerCode As String, ByVal name As
String, ByVal address As String, ByVal webSite As String) As Integer
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\MatrixProjects.mdb"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection(connectionString )

Dim queryString As String = "INSERT INTO [Manufacturer]
([ManufacturerCode], [Name], [Address], [WebSite]) VALUES (@ManufacturerCode,
@Name, @Address, @WebSite)"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dbParam_manufacturerCode As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_manufacturerCode.ParameterName = "@ManufacturerCode"
dbParam_manufacturerCode.Value = manufacturerCode
dbParam_manufacturerCode.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_manufacturerCode)
Dim dbParam_name As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_name.ParameterName = "@Name"
dbParam_name.Value = name
dbParam_name.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_name)
Dim dbParam_address As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_address.ParameterName = "@Address"
dbParam_address.Value = address
dbParam_address.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_address)
Dim dbParam_webSite As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_webSite.ParameterName = "@WebSite"
dbParam_webSite.Value = webSite
dbParam_webSite.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_webSite)

Dim rowsAffected As Integer = 0
dim ex as exception ' To see what error it is
dbConnection.Open
Try
rowsAffected = dbCommand.ExecuteNonQuery
Catch ex
msgLabel.Text = "Database Error: <br>" & ex.source & "<br>" & ex.message
& "<br>" & ex.stacktrace
msgLabel.Visible = true
Finally
dbConnection.Close
End Try

Return rowsAffected

End Function

The ex.message returns (danish):

"Handlingen skal bruge en opdaterbar forespørgsel"

which means something to the effect:

"Action needs an updatable query"

The ex.stacktrace says:

at System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(Int32 hr)
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS
dbParams, Object& executeResult) at
System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object& executeResult) at
System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior behavior,
Object& executeResult) at
System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior
behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at ASP.addManufacturer_aspx.InsertManufacturer(String manufacturerCode,
String name, String address, String webSite) in
C:\Inetpub\imcorp_asp\addManufacturer.aspx:line 58

Any idea? All other chapters worked like charm.

--
Cheers

Ekhaat

Nov 18 '05 #1
3 1804
which language was that..Austrian,Norwegian,finnish or swedish!
The "Action needs an updatable query" error if i recall means you don't have
permission to write to the database file!
So go the the folder where the file exist or the file and make sure you have
the right access to write to the file!
GDLUCK
Patrick

"Ekhaat" wrote:
Hi

I followed the Web Matrix guided tour and came to the "ASP.NET Pages with
Data
(Microsoft Access)" part.

There is really not much you can do wrong there, but for some reason, the
INSERT part gives me an error. Here is the function that fails (appart from
the exception handling everything is generated by the code wizard):

Function InsertManufacturer(ByVal manufacturerCode As String, ByVal name As
String, ByVal address As String, ByVal webSite As String) As Integer
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\MatrixProjects.mdb"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection(connectionString )

Dim queryString As String = "INSERT INTO [Manufacturer]
([ManufacturerCode], [Name], [Address], [WebSite]) VALUES (@ManufacturerCode,
@Name, @Address, @WebSite)"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dbParam_manufacturerCode As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_manufacturerCode.ParameterName = "@ManufacturerCode"
dbParam_manufacturerCode.Value = manufacturerCode
dbParam_manufacturerCode.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_manufacturerCode)
Dim dbParam_name As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_name.ParameterName = "@Name"
dbParam_name.Value = name
dbParam_name.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_name)
Dim dbParam_address As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_address.ParameterName = "@Address"
dbParam_address.Value = address
dbParam_address.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_address)
Dim dbParam_webSite As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_webSite.ParameterName = "@WebSite"
dbParam_webSite.Value = webSite
dbParam_webSite.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_webSite)

Dim rowsAffected As Integer = 0
dim ex as exception ' To see what error it is
dbConnection.Open
Try
rowsAffected = dbCommand.ExecuteNonQuery
Catch ex
msgLabel.Text = "Database Error: <br>" & ex.source & "<br>" & ex.message
& "<br>" & ex.stacktrace
msgLabel.Visible = true
Finally
dbConnection.Close
End Try

Return rowsAffected

End Function

The ex.message returns (danish):

"Handlingen skal bruge en opdaterbar forespørgsel"

which means something to the effect:

"Action needs an updatable query"

The ex.stacktrace says:

at System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(Int32 hr)
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS
dbParams, Object& executeResult) at
System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object& executeResult) at
System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior behavior,
Object& executeResult) at
System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior
behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at ASP.addManufacturer_aspx.InsertManufacturer(String manufacturerCode,
String name, String address, String webSite) in
C:\Inetpub\imcorp_asp\addManufacturer.aspx:line 58

Any idea? All other chapters worked like charm.

--
Cheers

Ekhaat

Nov 18 '05 #2
Ohhh...., You are the best, well, better than me anyway :-)

Thank you

"Patrick.O.Ige" wrote:
which language was that..Austrian,Norwegian,finnish or swedish!
The "Action needs an updatable query" error if i recall means you don't have
permission to write to the database file!
So go the the folder where the file exist or the file and make sure you have
the right access to write to the file!
GDLUCK
Patrick

"Ekhaat" wrote:
Hi

I followed the Web Matrix guided tour and came to the "ASP.NET Pages with
Data
(Microsoft Access)" part.

There is really not much you can do wrong there, but for some reason, the
INSERT part gives me an error. Here is the function that fails (appart from
the exception handling everything is generated by the code wizard):

Function InsertManufacturer(ByVal manufacturerCode As String, ByVal name As
String, ByVal address As String, ByVal webSite As String) As Integer
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\MatrixProjects.mdb"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection(connectionString )

Dim queryString As String = "INSERT INTO [Manufacturer]
([ManufacturerCode], [Name], [Address], [WebSite]) VALUES (@ManufacturerCode,
@Name, @Address, @WebSite)"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dbParam_manufacturerCode As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_manufacturerCode.ParameterName = "@ManufacturerCode"
dbParam_manufacturerCode.Value = manufacturerCode
dbParam_manufacturerCode.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_manufacturerCode)
Dim dbParam_name As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_name.ParameterName = "@Name"
dbParam_name.Value = name
dbParam_name.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_name)
Dim dbParam_address As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_address.ParameterName = "@Address"
dbParam_address.Value = address
dbParam_address.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_address)
Dim dbParam_webSite As System.Data.IDataParameter = New
System.Data.OleDb.OleDbParameter
dbParam_webSite.ParameterName = "@WebSite"
dbParam_webSite.Value = webSite
dbParam_webSite.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_webSite)

Dim rowsAffected As Integer = 0
dim ex as exception ' To see what error it is
dbConnection.Open
Try
rowsAffected = dbCommand.ExecuteNonQuery
Catch ex
msgLabel.Text = "Database Error: <br>" & ex.source & "<br>" & ex.message
& "<br>" & ex.stacktrace
msgLabel.Visible = true
Finally
dbConnection.Close
End Try

Return rowsAffected

End Function

The ex.message returns (danish):

"Handlingen skal bruge en opdaterbar forespørgsel"

which means something to the effect:

"Action needs an updatable query"

The ex.stacktrace says:

at System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(Int32 hr)
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS
dbParams, Object& executeResult) at
System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object& executeResult) at
System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior behavior,
Object& executeResult) at
System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior
behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at ASP.addManufacturer_aspx.InsertManufacturer(String manufacturerCode,
String name, String address, String webSite) in
C:\Inetpub\imcorp_asp\addManufacturer.aspx:line 58

Any idea? All other chapters worked like charm.

--
Cheers

Ekhaat

Nov 18 '05 #3
No worries Ekhaat...
By the way i speak Danish!!!!!!!!

Enjoy
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Randell D. | last post by:
Folks, I use PHP to write my form data to MySQL. I have a database with about ten tables. I'm trying to fill one table with some dummy data (its a contact manager table holding names of...
3
by: Gigi.com | last post by:
Hi All. I need some help trying to pull prices from a price matrix. Here's an example: >>>> 1000 1500 2000 2500 ----------------------------------------- 1000 ¦ 10.20 ...
16
by: raj | last post by:
Hi, I saw it mentioned that "int" is the fastest data-type for use in C ,that is data storage/retrieval would be the fastest if I use int among the following 4 situations in a 32 bit machine with...
3
by: Bob Alston | last post by:
I have a routine to copy data to new versions of my app via insert into sql statements. Unfortunately, due to evolution of my app, sometimes the new version has more restrictive editing than an...
3
by: nolanmadson | last post by:
I'm creating a front-end for some Teradata user maintenance tables in MS Access. I've started having problems in occasionally not being able to insert or update records in these tables. I've been...
232
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first...
1
by: Peterwkc | last post by:
Hello all expert, i have two program which make me desperate bu after i have noticed the forum, my future is become brightness back. By the way, my problem is like this i the first program was...
3
by: robert | last post by:
Often I want to extract some web table contents. Formats are mostly static, simple text & numbers in it, other tags to be stripped off. So a simple & fast approach would be ok. What of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.