ASP.NET -> Database

D

Davy Marichael

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,
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..
 
E

Elton Wang

The ASPNET account should have 'Write' permission of the
access file.

HTH

Elton Wang
(e-mail address removed)
 
A

Asshen Shugar

Check the permissions.


Davy Marichael said:
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,

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..
 
Top