Wednesday, March 7, 2012

is it a bug in SSCE OLEDB ?

i'm use this code ,in SQL2005 std and ACCESS database, it work

but if i use SSCE ,it's throw a OleDbException in ExecuteScalar()

Exception : OleDbException

0x80040E30L

DB_E_BADTYPENAME

Code Snippet

OleDbConnection od = new OleDbConnection("Provider=Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source=db.sdf;SSCE:Database Password=");

od.Open();

OleDbCommand og = new OleDbCommand("INSERT INTO [bills] ([billno],[checkouttime],[finalprice],[handle],[ischeckout],[memo],[paymode],[trick]) VALUES (@.billno,@.checkouttime,@.finalprice,@.handle,@.ischeckout,@.memo,@.paymode,@.trick)", od);

og.Parameters.Add("@.billno", OleDbType.VarWChar).Value = "2007051800000000";
og.Parameters.Add("@.checkouttime",OleDbType.DBTimeStamp).Value="2007-5-18 11:55:40";
og.Parameters.Add("@.finalprice", OleDbType.Single).Value = 0.0;
og.Parameters.Add("@.handle", OleDbType.VarWChar).Value = "admin";
og.Parameters.Add("@.ischeckout", OleDbType.SmallInt).Value = 0;
og.Parameters.Add("@.memo", OleDbType.VarWChar).Value = "";
og.Parameters.Add("@.paymode", OleDbType.VarWChar).Value = "";
og.Parameters.Add("@.trick", OleDbType.VarWChar).Value = "";

og.ExecuteScalar();

od.Close();

why the same code is not work? i'm find all MSDN ,but there is no answer

Who can help me,Thanks

SSCE is not registered as a standard oledb provider. We have a *limited* support for OLEDB. It doesn't comply with tier-1 or tier-2 requirements etc. Why don't you use our managed provider? Things are much more fun. If you have to use native provider only, you will have to use standard oledb interfaces like IDBInitialize, ICommand etc.

You can even search for oledb northwind sample on msdn. If your question is answered, please mark it as answered.

Thanks

Raja

|||Have you tried using ExecuteNonQuery in stead of ExecuteScalar

|||

Please try using double quotes instead of brackets to delimit identifiers. The SQL Compact Edition 3.0 query processor does not accept Access' brackets. Try this statement:

Code Snippet

INSERT INTO "bills" ("billno", "checkouttime", "finalprice", "handle", "ischeckout", "memo", "paymode", "trick") VALUES (...)

|||

Jo?o Paulo Figueira wrote:

Please try using double quotes instead of brackets to delimit identifiers. The SQL Compact Edition 3.0 query processor does not accept Access' brackets. Try this statement:

Code Snippet

INSERT INTO "bills" ("billno", "checkouttime", "finalprice", "handle", "ischeckout", "memo", "paymode", "trick") VALUES (...)

yes,it's works

but,i want to use the same code on SSEE SSCE ACCESS

so i use OLEDB parameter ,but it's error

|||

Rajagopal R V wrote:

SSCE is not registered as a standard oledb provider. We have a *limited* support for OLEDB. It doesn't comply with tier-1 or tier-2 requirements etc. Why don't you use our managed provider? Things are much more fun. If you have to use native provider only, you will have to use standard oledb interfaces like IDBInitialize, ICommand etc.

You can even search for oledb northwind sample on msdn. If your question is answered, please mark it as answered.

Thanks

Raja

the SSCE managed provider is sqlceconnection ,the SSEE managed provider is sqlconnection

if i use this provider ,i will write 3 different query on SSEE SSCE ACCESS

don't have an easy Method ?

thanks

|||

You could use database independent base classes in your code (e.g. DbConnection) and specific providers for each database:

DbConnection connection = new SqlConnection(...); // Or SqlCeConnection or whatever else.

connection.Open();

DbCommand command = connection.CreateCommand();

command.CommandText = "Select whatever from somewhere where some = ?";

command.Parameter.Add(...);

Usually it makes little sense because SQL dialects are slightly different and query for one database won’t work on another (unless it’s really basic).

No comments:

Post a Comment