Problem: Insert one single record in a access DB using DB
From: appiez_at_bierquick.nl ((appiez_at_bierquick.nl))
Date: 06/23/04
- Next message: ckone: "Switchboards Access 2000"
- Previous message: Peter Gruendler: "VBscript Error 800a01a8 on Connection.Close"
- Next in thread: Val Mazur: "Re: Problem: Insert one single record in a access DB using DB"
- Reply: Val Mazur: "Re: Problem: Insert one single record in a access DB using DB"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 23 Jun 2004 03:25:36 -0700
Hi all,
I encounter a strange problem wich follows me for a while now. Recently I developed a website in asp.net wich usses a 2002 access DB. At one point the user submits his entries and I insert them in the Database. Here comes the problem: Sometimes Access or ADO inserts MULTIPLE records (with the same value's) instead of just ONE!!
here is my insert code:
Public Function savePrediction(ByRef value As Prediction, ByVal cn As OleDb.OleDbConnection) As Boolean
Try
Const sqlString As String = "INSERT INTO Predictions (MatchId, UserId, HomePrediction, AwayPrediction) VALUES " & _
"(@MatchId, @UserId, @HomePrediction, @AwayPrediction)"
Dim myCommand As New OleDb.OleDbCommand(sqlString, cn)
myCommand.Parameters.Add(New OleDb.OleDbParameter("@MatchId", value.MatchId))
myCommand.Parameters.Add(New OleDb.OleDbParameter("@UserId", value.UserId))
myCommand.Parameters.Add(New OleDb.OleDbParameter("@HomePrediction", value.HomePrediction))
myCommand.Parameters.Add(New OleDb.OleDbParameter("@AwayPrediction", value.AwayPrediction))
cn.Open()
myCommand.ExecuteNonQuery()
cn.Close()
myCommand.Dispose()
Return True
Catch
Return False
End Try
End Function
No wierd insert command in my opinion. Anybody an idea of what might be the problem?
**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
- Next message: ckone: "Switchboards Access 2000"
- Previous message: Peter Gruendler: "VBscript Error 800a01a8 on Connection.Close"
- Next in thread: Val Mazur: "Re: Problem: Insert one single record in a access DB using DB"
- Reply: Val Mazur: "Re: Problem: Insert one single record in a access DB using DB"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|