473,503 Members | 2,107 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.NET -> Database

Hi,

i'm having problems with the insert command in .NET
The Select statement works perfectly, but insert.. He gives an error when he
executes the command:
ExecuteNonQuery()

I'm working with access 2000, and there are no passwd/users to access the
db..
The error is: Couldn't find database,
but for the select method he DOES find the db..


Check the code below..
Thanx in advance!

Public Sub voegToe(ByVal aproduct As Product)

Dim oConn As New OleDbConnection(mStrConn)

Dim sqlCmd As String = "INSERT INTO Product (ProductName, Color, Sizes, M_F,
Price, ProductTypeID, ProductClassID, UnitsInStock) VALUES (@ProductName,
@Color, @Sizes, @M_F, @Price, @ProductTypeID, @ProductClassID,
@UnitsInStock)"

Dim oCmd As New OleDbCommand(sqlCmd, oConn)

oCmd.Parameters.Add(New OleDbParameter("@ProductName", aproduct.Naam))

oCmd.Parameters.Add(New OleDbParameter("@Color", aproduct.Kleur))

oCmd.Parameters.Add(New OleDbParameter("@Sizes", aproduct.Maat))

oCmd.Parameters.Add(New OleDbParameter("@M_F", aproduct.M_F))

oCmd.Parameters.Add(New OleDbParameter("@Price", aproduct.Prijs))

oCmd.Parameters.Add(New OleDbParameter("@ProductTypeID", aproduct.TypeID))

oCmd.Parameters.Add(New OleDbParameter("@ProductClass", aproduct.ClassID))

oCmd.Parameters.Add(New OleDbParameter("@UnitsInStock", aproduct.Voorraad))

Try

oConn.Open()

oCmd.ExecuteNonQuery()

oConn.Close()

Catch ex As Exception

Throw New Exception("Database niet gevonden")

oConn.Close()

End Try

End Sub

My DB is added in the config file so i don't know what the problem COULD
be..

I have the same problem with UPDATE & DELETE... Only SELECT works..

Nov 19 '05 #1
2 1066
The ASPNET account should have 'Write' permission of the
access file.

HTH

Elton Wang
el********@hotmail.com
-----Original Message-----
Hi,

i'm having problems with the insert command in .NET
The Select statement works perfectly, but insert.. He gives an error when heexecutes the command:
ExecuteNonQuery()

I'm working with access 2000, and there are no passwd/users to access thedb..
The error is: Couldn't find database,
but for the select method he DOES find the db..

Check the code below..
Thanx in advance!

Public Sub voegToe(ByVal aproduct As Product)

Dim oConn As New OleDbConnection(mStrConn)

Dim sqlCmd As String = "INSERT INTO Product (ProductName,

Color, Sizes, M_F,Price, ProductTypeID, ProductClassID, UnitsInStock) VALUES (@ProductName,@Color, @Sizes, @M_F, @Price, @ProductTypeID, @ProductClassID,@UnitsInStock)"

Dim oCmd As New OleDbCommand(sqlCmd, oConn)

oCmd.Parameters.Add(New OleDbParameter("@ProductName", aproduct.Naam))
oCmd.Parameters.Add(New OleDbParameter("@Color", aproduct.Kleur))
oCmd.Parameters.Add(New OleDbParameter("@Sizes", aproduct.Maat))
oCmd.Parameters.Add(New OleDbParameter("@M_F", aproduct.M_F))
oCmd.Parameters.Add(New OleDbParameter("@Price", aproduct.Prijs))
oCmd.Parameters.Add(New OleDbParameter("@ProductTypeID", aproduct.TypeID))
oCmd.Parameters.Add(New OleDbParameter("@ProductClass", aproduct.ClassID))
oCmd.Parameters.Add(New OleDbParameter("@UnitsInStock", aproduct.Voorraad))
Try

oConn.Open()

oCmd.ExecuteNonQuery()

oConn.Close()

Catch ex As Exception

Throw New Exception("Database niet gevonden")

oConn.Close()

End Try

End Sub

My DB is added in the config file so i don't know what the problem COULDbe..

I have the same problem with UPDATE & DELETE... Only SELECT works..
.

Nov 19 '05 #2
Check the permissions.
"Davy Marichael" <da***@pandora.be> wrote in message
news:uz**************@TK2MSFTNGP12.phx.gbl...
Hi,

i'm having problems with the insert command in .NET
The Select statement works perfectly, but insert.. He gives an error when
he
executes the command:
ExecuteNonQuery()

I'm working with access 2000, and there are no passwd/users to access the
db..
The error is: Couldn't find database,
but for the select method he DOES find the db..


Check the code below..
Thanx in advance!

Public Sub voegToe(ByVal aproduct As Product)

Dim oConn As New OleDbConnection(mStrConn)

Dim sqlCmd As String = "INSERT INTO Product (ProductName, Color, Sizes,
M_F,
Price, ProductTypeID, ProductClassID, UnitsInStock) VALUES (@ProductName,
@Color, @Sizes, @M_F, @Price, @ProductTypeID, @ProductClassID,
@UnitsInStock)"

Dim oCmd As New OleDbCommand(sqlCmd, oConn)

oCmd.Parameters.Add(New OleDbParameter("@ProductName", aproduct.Naam))

oCmd.Parameters.Add(New OleDbParameter("@Color", aproduct.Kleur))

oCmd.Parameters.Add(New OleDbParameter("@Sizes", aproduct.Maat))

oCmd.Parameters.Add(New OleDbParameter("@M_F", aproduct.M_F))

oCmd.Parameters.Add(New OleDbParameter("@Price", aproduct.Prijs))

oCmd.Parameters.Add(New OleDbParameter("@ProductTypeID", aproduct.TypeID))

oCmd.Parameters.Add(New OleDbParameter("@ProductClass", aproduct.ClassID))

oCmd.Parameters.Add(New OleDbParameter("@UnitsInStock",
aproduct.Voorraad))

Try

oConn.Open()

oCmd.ExecuteNonQuery()

oConn.Close()

Catch ex As Exception

Throw New Exception("Database niet gevonden")

oConn.Close()

End Try

End Sub

My DB is added in the config file so i don't know what the problem COULD
be..

I have the same problem with UPDATE & DELETE... Only SELECT works..

Nov 19 '05 #3

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

Similar topics

0
1042
by: Jim Douglas | last post by:
Are other's using the .NET stuff like this? Do you use the Dataobject or include the data access stuff in the BusinessObject? Does everyone use storedprocedures? Thanks! Jim Douglas...
1
1171
by: Davy Marichael | last post by:
Hi, i'm having problems with the insert command in .NET The Select statement works perfectly, but insert.. He gives an error when he executes the command: ExecuteNonQuery() Check the code...
1
2177
by: ===Steve L.=== | last post by:
I'm new to vb studio .net and sql2k, and wondered if any one know any good articles on the subject? such as the best practices and configuration for the database connection and security model....
2
1815
by: hawat.thufir | last post by:
cross-posted to: mailing.database.myodbc,comp.text.xml I have an xhtml file whose data I'd like to import to MySQL. Unfortunately, mysqlimport will only work with text files. Mixed in with text...
1
2239
by: MAILTONRK | last post by:
Hi, I am a Mainframe guy. I am working with MS access(maintaining a application) for the last 2 weeks. I had one master database and four replicas. One of my replica had trouble in...
5
1421
by: David Harris | last post by:
I am developing a type of data warehouse. Basically, we have 20 client survey machines that are each separated from the server by space and lack of network. Yet both need to speak to each other...
1
4102
by: masoumeh | last post by:
please help me I use this code TA_Insert_Language as new DataSetName.Insert_LanguageTableAdapter DT_Insert_Language as new DataSetName.Insert_LanguageDataTable dim MaxRow as new DataRow dim...
0
864
by: Don Miller | last post by:
It seems fairly straightforward to serialize a custom object to an XML file (saved in the file system) but it is wide open on how to serialize that object as a stream and then get it into a...
1
1294
Plater
by: Plater | last post by:
I don't think I brought this up before, so I'm going to ask it. My recent style of using a database in my applications (web-based and windows-based) has been to create a static class called...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
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
7287
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,...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4689
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3170
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.