Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need help here...I'm not good in using Oracle Connection in VB.Net. I encountered the above error: ORA-01008: not all variables bound.
Below are my codes in VB.Net. Appreciate if you could help me to resolve the problem. Thank you.

VB
Dim iRet As Integer = 0
sSql = "INSERT INTO RECIPEINFO VALUES('" & sRecipeName & _
"','" & sMcNo & "','" & sMcType & "','" & sLotNo & "','" & sDevice & _
"','" & sRecipeStatus & "','" & sEmpNo & "','" & sIndicator & "','" & sMode & "',:DateTime,:Data)"
'cmd = New SqlCommand(sSql, myConnection)
cmd = New OracleCommand(sSql, myConnection)

cmd.Parameters.Add(New OracleParameter(":Data", OracleDbType.Blob, 500, "Data"))
cmd.Parameters.Item(":Data").Value = buffer

'executing the command and assigning it to connection
iRet = cmd.ExecuteNonQuery()
cmd = Nothing
myConnection.Close()
Posted
Updated 13-Oct-11 6:28am
v2

1 solution

You must add a parameter for :DateTime like you've done for :Data, or remove :DateTime from your sql
 
Share this answer
 
Comments
mlco76 13-Oct-11 20:36pm    
After putting in the DateTime values, I encounter a new error this time.
"ORA-00913: too many values"
Below are my coding.
Dim iRet As Integer = 0
sSql = "INSERT INTO RECIPEINFO VALUES('" & sRecipeName & _
"','" & sMcNo & "','" & sMcType & "','" & sLotNo & "','" & sDevice & _
"','" & sRecipeStatus & "','" & sEmpNo & "','" & sIndicator & "','" & sMode & "',:DateTime,:Data)"
cmd = New OracleCommand(sSql, myConnection)

cmd.Parameters.Add(New OracleParameter(":Data", OracleDbType.Blob))
cmd.Parameters.Item(":Data").Value = buffer

cmd.Parameters.Add(New OracleParameter(":DateTime", OracleDbType.Date))
cmd.Parameters(":DateTime").Value = Now

'executing the command and assigning it to connection
iRet = cmd.ExecuteNonQuery()
cmd = Nothing
myConnection.Close()

Btw, thank you Simon for your prompt reply.
Simon Bang Terkildsen 14-Oct-11 5:52am    
That's likely because you don't have as many columns in your table as the number of values you're trying to insert into the new row.
mlco76 14-Oct-11 3:21am    
Now I encounter this error: "ORA-00932: inconsistent datatypes: expected NUMBER got BLOB".

How to resolve this? Thank you.
Simon Bang Terkildsen 14-Oct-11 5:54am    
That's because you're trying to insert a number (integer, double, ect.) into a column that has the type BLOB.
Remember when you write VALUES(...) in your sql the values must be specified in the exact same order as your columns is defined in the table, unless you state the columns in your sql, which you don't in the posted sql.
mlco76 18-Oct-11 22:12pm    
Thanks Simon...I've resolved my problem already. Thank you for your hints.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900