OLE DB Command fails when having more than one Parameter objects
i have sql ce database. company table exists in database. company has id(10), name(50) nvarchar fields. i'm trying query table following select statement whole process crashes. here im using ole db namespace bcz have support different types of databases. oledbconnection olecon = new oledbconnection(); olecon.connectionstring = "provider=microsoft.sqlserver.ce.oledb.3.5;data source=" + directory.getparent(application.executablepath) + @"\database1.sdf"; olecon.open(); oledbcommand cmd = new oledbcommand(); cmd.commandtext = "select * company id = @id , name= @name"; cmd.connection = olecon; cmd.parameters.addwithvalue("@id", "abc"); cmd.parameters.addwithvalue("@name", "name"); oledbdataadapter adp = new oledbdataadapter(cmd); adp.fill(dt); //line of code fails con.close();
as have read on forum, there had been problems regarding parameteres sql ce 3.5 try using sql ce 3.5sp1 instead.
reference:
http://social.msdn.microsoft.com/forums/en-us/sqlce/thread/5de469d1-d0e3-4d5a-a1ed-a62323687bb8
hannes
if have got questions this, ask.
in perfect world,
users never enter data in wrong form,
files choose open exist
, code never have bugs.
c# vb.net: http://www.developerfusion.com/tools/convert/csharp-to-vb/
Visual Studio Languages , .NET Framework > Visual C#
Comments
Post a Comment