stehtimschilf
New member
- Joined
- Sep 3, 2009
- Messages
- 4
- Programming Experience
- Beginner
Hi
I'm just wondering why I get this error:
OleDbCommand.Prepare method requires all variable length parameters to have an explicitly set non-zero Size.
With this simple lines of code:
I may avoid the mentioned error if I do not use parameters in my select stmt (e.g. Account_ID = 3 instead of Account_ID = ?). But I want to use OleDbParameters.
Why can't I access the property 'cmdBuilder.GetUpdateCommand().CommandText' ?
As mentioned, the GetUpdateCommand().CommandText-Property is available if I do not user any parameters in the select stmt.
thx in advanced!
SiS
BE-Database: MS Access 2007
I'm just wondering why I get this error:
OleDbCommand.Prepare method requires all variable length parameters to have an explicitly set non-zero Size.
With this simple lines of code:
VB.NET:
Dim con As New OleDbConnection(getConnectionString(1))
strSQL = _
"SELECT Account_ID, Account_Password, Account_Password_old, Account_Password_set " & _
"FROM ACCOUNTS " & _
"WHERE (Account_ID = ?) " & _
"AND (Account_Username = ?) " & _
"AND (Account_Password = ?) "
Dim cmd As OleDbCommand = New OleDbCommand(strSQL, con)
cmd.Parameters.Add(New OleDbParameter("@ParameterAccountID", auth.AccountID)).OleDbType = OleDbType.Integer
cmd.Parameters.Add(New OleDbParameter("@ParameterAccountUsername", auth.Username)).OleDbType = OleDbType.VarChar
cmd.Parameters.Add(New OleDbParameter("@ParameterAccountPassword", auth.Password)).OleDbType = OleDbType.VarChar
Dim da As OleDbDataAdapter = New OleDbDataAdapter(cmd)
Dim ds As New DataSet
con.Open()
da.Fill(ds)
Dim cmdBuilder As New OleDbCommandBuilder(da)
'Next line invokes the error
writeToErrorLogFile(cmdBuilder.GetUpdateCommand.CommandText)
I may avoid the mentioned error if I do not use parameters in my select stmt (e.g. Account_ID = 3 instead of Account_ID = ?). But I want to use OleDbParameters.
Why can't I access the property 'cmdBuilder.GetUpdateCommand().CommandText' ?
As mentioned, the GetUpdateCommand().CommandText-Property is available if I do not user any parameters in the select stmt.
thx in advanced!
SiS
BE-Database: MS Access 2007