|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
vfp oledbcommand [Fail]Dim authConnection As New OleDbConnection("Provider =
VfpOleDB.1;Data Source = d:\cgl\vfpmaster\ttsdata\tts.dbc") authConnection.Open() Dim authCommand As String = "select loginid from coinfo where loginid = @cocode " oleCommand.Parameters.Add("@cocode", OleDbType.VarChar, 10).Value = "1001" or oleCommand.Parameters.Add(new oledbparameter("@cocode", OleDbType.VarChar, 10)).Value = "1001" Dim drRv As OleDbDataReader = oleCommand.ExecuteReader <---ERROR Please help, I don't know what's wrong with my statment. For the same syntax, I can run very well in my sql server, However, When I change into oleddb command. I got "missing operand" error. Agnes,
What is the meaning from this boolean code that you are using? oleCommand.Parameters.Add("@cocode", OleDbType.VarChar, 10).Value = "1001" or oleCommand.Parameters.Add(new oledbparameter("@cocode", OleDbType.VarChar, 10)).Value = "1001" In my idea does it nothing Cor Show quoteHide quote "Agnes" <ag***@dynamictech.com.hk> schreef in bericht news:uAQUNOsyGHA.3512@TK2MSFTNGP04.phx.gbl... > Dim authConnection As New OleDbConnection("Provider = > VfpOleDB.1;Data Source = d:\cgl\vfpmaster\ttsdata\tts.dbc") > authConnection.Open() > Dim authCommand As String = "select loginid from coinfo > where loginid = @cocode " > > oleCommand.Parameters.Add("@cocode", OleDbType.VarChar, > 10).Value = "1001" > or oleCommand.Parameters.Add(new oledbparameter("@cocode", > OleDbType.VarChar, 10)).Value = "1001" > Dim drRv As OleDbDataReader = > oleCommand.ExecuteReader <---ERROR > > Please help, I don't know what's wrong with my statment. > For the same syntax, I can run very well in my sql server, > However, When I change into oleddb command. > I got "missing operand" error. > > > > > I want to pass the company code '1001' as parameter to the command text.
Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> ¼¶¼g©ó¶l¥ó·s»D:%23mbbXNzyGHA.5***@TK2MSFTNGP05.phx.gbl... > Agnes, > > What is the meaning from this boolean code that you are using? > > oleCommand.Parameters.Add("@cocode", OleDbType.VarChar, > 10).Value = "1001" > or oleCommand.Parameters.Add(new oledbparameter("@cocode", > OleDbType.VarChar, 10)).Value = "1001" > > > In my idea does it nothing > > Cor > > "Agnes" <ag***@dynamictech.com.hk> schreef in bericht > news:uAQUNOsyGHA.3512@TK2MSFTNGP04.phx.gbl... >> Dim authConnection As New OleDbConnection("Provider = >> VfpOleDB.1;Data Source = d:\cgl\vfpmaster\ttsdata\tts.dbc") >> authConnection.Open() >> Dim authCommand As String = "select loginid from coinfo >> where loginid = @cocode " >> >> oleCommand.Parameters.Add("@cocode", OleDbType.VarChar, >> 10).Value = "1001" >> or oleCommand.Parameters.Add(new oledbparameter("@cocode", >> OleDbType.VarChar, 10)).Value = "1001" >> Dim drRv As OleDbDataReader = >> oleCommand.ExecuteReader <---ERROR >> >> Please help, I don't know what's wrong with my statment. >> For the same syntax, I can run very well in my sql server, >> However, When I change into oleddb command. >> I got "missing operand" error. >> >> >> >> >> > > Brrrrrrrrr
That or is in your message is no code but a seperator of two possibilities. An error that mostly is done by OleDB is that there are added to many times a paramaeter. If you add it than you add it to an array, that array it is using. Therefore you should only add them one time and than change the value as often as you want. Have a look at this page how to use OleDB parameters. http://www.vb-tips.com/dbpages.aspx?ID=550279ec-6767-44ff-aaa3-eb8b44af0137 I hope this helps, Cor Show quoteHide quote "Agnes" <ag***@dynamictech.com.hk> schreef in bericht news:%23$vXWb0yGHA.4968@TK2MSFTNGP05.phx.gbl... >I want to pass the company code '1001' as parameter to the command text. > > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> > ¼¶¼g©ó¶l¥ó·s»D:%23mbbXNzyGHA.5***@TK2MSFTNGP05.phx.gbl... >> Agnes, >> >> What is the meaning from this boolean code that you are using? >> >> oleCommand.Parameters.Add("@cocode", OleDbType.VarChar, >> 10).Value = "1001" >> or oleCommand.Parameters.Add(new oledbparameter("@cocode", >> OleDbType.VarChar, 10)).Value = "1001" >> >> >> In my idea does it nothing >> >> Cor >> >> "Agnes" <ag***@dynamictech.com.hk> schreef in bericht >> news:uAQUNOsyGHA.3512@TK2MSFTNGP04.phx.gbl... >>> Dim authConnection As New OleDbConnection("Provider = >>> VfpOleDB.1;Data Source = d:\cgl\vfpmaster\ttsdata\tts.dbc") >>> authConnection.Open() >>> Dim authCommand As String = "select loginid from coinfo >>> where loginid = @cocode " >>> >>> oleCommand.Parameters.Add("@cocode", OleDbType.VarChar, >>> 10).Value = "1001" >>> or oleCommand.Parameters.Add(new oledbparameter("@cocode", >>> OleDbType.VarChar, 10)).Value = "1001" >>> Dim drRv As OleDbDataReader = >>> oleCommand.ExecuteReader <---ERROR >>> >>> Please help, I don't know what's wrong with my statment. >>> For the same syntax, I can run very well in my sql server, >>> However, When I change into oleddb command. >>> I got "missing operand" error. >>> >>> >>> >>> >>> >> >> > > Hi Agnes,
"@" preceding a variable name has a different use in FoxPro than it does in SQL Server. This works for me: Try Dim cn1 As New OleDbConnection( _ "Provider=VFPOLEDB.1;Data Source=C:\Temp\;") cn1.Open() '-- Make some VFP data to play with Dim cmd1 As New OleDbCommand( _ "Create Table TestParameter (Field1 C(10))", cn1) Dim cmd2 As New OleDbCommand( _ "Insert Into TestParameter Values ('Hello')", cn1) Dim cmd3 As New OleDbCommand( _ "Insert Into TestParameter Values ('World')", cn1) cmd1.ExecuteNonQuery() cmd2.ExecuteNonQuery() cmd3.ExecuteNonQuery() Dim cmd4 As New OleDbCommand( _ "Select * From TestParameter Where Field1 = ?", cn1) Dim p1 As New OleDbParameter("Field1", "World") Dim da1 As New OleDbDataAdapter(cmd4) Dim ds1 As New DataSet Dim dr1 As DataRow cmd4.Parameters.Add(p1) da1.Fill(ds1) For Each dr1 In ds1.Tables(0).Rows Console.WriteLine(dr1.Item(0).ToString()) Next Console.ReadLine() cn1.Close() Catch e As Exception MsgBox(e.ToString()) End Try -- Show quoteHide quoteCindy Winegarden MCSD, Microsoft Most Valuable Professional ci***@cindywinegarden.com "Agnes" <ag***@dynamictech.com.hk> wrote in message news:uAQUNOsyGHA.3512@TK2MSFTNGP04.phx.gbl... > Dim authConnection As New OleDbConnection("Provider = > VfpOleDB.1;Data Source = d:\cgl\vfpmaster\ttsdata\tts.dbc") > authConnection.Open() > Dim authCommand As String = "select loginid from coinfo > where loginid = @cocode " > > oleCommand.Parameters.Add("@cocode", OleDbType.VarChar, > 10).Value = "1001" > or oleCommand.Parameters.Add(new oledbparameter("@cocode", > OleDbType.VarChar, 10)).Value = "1001" > Dim drRv As OleDbDataReader = > oleCommand.ExecuteReader <---ERROR > > Please help, I don't know what's wrong with my statment. > For the same syntax, I can run very well in my sql server, > However, When I change into oleddb command. > I got "missing operand" error. > > > > > |
|||||||||||||||||||||||