Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
.NET equivalent of
Message
 
 
To
06/11/2006 15:10:51
Alexandre Palma
Harms Software, Inc.
Alverca, Portugal
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro and .NET
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01167436
Message ID:
01167451
Views:
7
Alexandre,

Thanks for the response!

I know I don't have to dictate the size, but even dictating the data type is a pain. I mean, there is no syntactic difference between text, varchar, and char, for example. Why do I have to declare types? SQL Server will accept anything in single quotes in these cases (for date/times, too!).

And if I need different syntax for OleDb vs SQL, I might as well just generate the SQL strings using switch statements (based on type of the value being passed) in my base data access class. I want the end-developer code to be consistent, using the same syntax for parameters and not needing to worry about data types. In other words, I want to be able to do:
SQLUtil oSQL = new SQLUtil();
string lcSQL;
lcSQL = "INSERT INTO SysError VALUES (?CreatedOn, ?ErrMessage)"
oSQL.SetParameter("?CreatedOn", DateTime.Now);
oSQL.SetParameter("?ErrMessage", Err.Message);
oSQL.Exec(lcSQL);
to write data to SQL Server, and then be able to also do:
DBFUtil oDBF = new DBFUtil();
string lcSQL;
lcSQL = "INSERT INTO C:\Data\SysError VALUES (?CreatedOn, ?ErrMessage)"
oDBF.SetParameter("?CreatedOn", DateTime.Now);
oDBF.SetParameter("?ErrMessage", Err.Message);
return oDBF.Exec(lcSQL);
to DBF data. Notice that the only differences are the utility objects I start with. I want all other syntax to be consistent. Even the paths to DBF tables can be abstracted out by making the DBF object use our global DBF definition table that we already have in place. SQLUtil and DBFUtil will have some methods unique to themselves, but overall usage will be transparent. The objects will be able to do INSERTs, UPDATEs, and DELETEs, and I am overloading the Exec mthod to allow a dataset to be passed in for SELECT statements -- one SQL statement will fill a dataset just like VFP's SQLEXEC() can do now.

The bottom line for me is that VFP's SQL Passthrough already had the "?" syntax working. Using SQLEXEC(), I could write to any SQL Server, OLEDB, or ODBC data source using a common syntax. It is disappointing that such a rich set of objects like ADO.Net cannot afford me the same luxury. :\ Looks like I'll have to roll my own syntactic sugar. *smile*

Thanks again,
JoeK

>You can specify parameters in .net just by specifying the name and the type, no need for the lenght, what you need to have into consideration is that Sql Server uses parameters names while VFP OLEDB doesn't.
>also the SQL is a litle diferent so while for sql server you end up having something like INSERT INTO mytable (field1, field2, field3, ...fieldn) VALUES (@par1, @par2, @par3, ...@parn).
>In VFP you will need INSERT INTO my mytable (field1, field2, field3, ...fieldn) VALUES (?, ?, ?,...?).
>If you try to use names it will raise an error.
Previous
Reply
Map
View

Click here to load this message in the networking platform