Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > ASP -> Database (Insert)

Reply
Thread Tools

ASP -> Database (Insert)

 
 
Davy Marichael
Guest
Posts: n/a
 
      03-29-2005
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 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..



 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      03-29-2005
Davy Marichael wrote:
> Hi,
>
> i'm having problems with the insert command in .NET



There was no way for you to know it, but this is a classic asp newsgroup.
While you may be lucky enough to find a dotnet-savvy person here who can
answer your question, you can eliminate the luck factor by posting your
question to a group where those dotnet-savvy people hang out. I suggest
microsoft.public.dotnet.framework.aspnet.

More below ...

> The Select statement works perfectly, but insert.. He gives an error


We're not psychic. What error?

> when he executes the command:
> ExecuteNonQuery()


> Check the code below..
> Thanx in advance!

<snip>
>
>
> My DB


.... which you have not specified. The person helping you with this problem
will need to know the type and version of the database you are using.

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


You have not mentioned what the error was. Please try to describe your
symptoms without using the words " doesn't work"

Based on this last sentence, it looks like you are having a permissions
problem. If it's an Access database (again, please do not make us guess),
then you need to realize that all users of the database require read/write
permissions for the folder containing the database file. This includes the
aspnet user account under which your asp.net process is running.

Bob Barrows


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
 
 
Reply

Thread Tools

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Database Database Database Database scott93727@gmail.com Computer Information 0 09-27-2012 02:43 AM
DataBase DataBase DataBase DataBase scott93727@gmail.com Computer Information 0 09-26-2012 09:40 AM
exporting an excel file from database; making changes to excel file and updating the database by importing it back Luis Esteban Valencia ASP .Net 1 01-12-2005 12:28 AM
Re: Software Developer to transcribe Oracle database into Access database Fluker MCSD 0 07-09-2003 01:20 PM
Re: Software Developer to transcribe Oracle database into Access database Guy Cox MCSD 1 07-09-2003 08:07 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57