Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Improperly defined parameter object 1

Status
Not open for further replies.

msturges

Programmer
Mar 29, 2001
32
ZA
Hi,

I'm trying to write data to a SQL Server 7 DB. No matter what I try I keep getting the same error:"The application has improperly defined a parameter object".

I don't understand why I keep getting this problem, after all I used the exact same coding in a previous project and it worked 100%.

I'm using the following code:

Dim oConn As Object
Dim cmUpdTop As Object

'Open a connection to the EDIBILLING DSN
Set oConn = CreateObject("ADODB.Connection")
oConn.Open "DSN=EDIBILLING;UID=sa"

' Instantiate the command for cmUpdateTop20 object
Set cmUpdTop = CreateObject("ADODB.Command")
Set cmUpdTop.ActiveConnection = oConn
'Build insert statement for
cmUpdTop.CommandText = "INSERT INTO MonthlyTop20 _(Month ,Position, Customer, Volume) VALUES (?,?,?,?)"
cmUpdTop.Prepared = True

With cmUpdTop
.Parameters.Append .CreateParameter("Month", adChar, ,_ 15)
.Parameters.Append .CreateParameter("Position",_ adInteger, , 9)
.Parameters.Append .CreateParameter("Customer",_ adChar, , 50)
.Parameters.Append .CreateParameter("Volume",_ adInteger, , 9)
End With



If anyone can shed some light on the situation for me, it would be greatly appreciated.

thanx
mike
 
You need to specify the field width for your character parameter ("Customer"). You're also passing it the value 50, and it should be a string containing your customer name.

I also saw that you're using 15 for the month, when there's only 12 months in a year ;-). I think you need to check the parameters needed for a CreateParameter().

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top