Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
.NET equivalent of
Message
From
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:
01167447
Views:
6
Hi Joe,
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.

>Hey all,
>
>We are finally taking the .NET plunge, and I have been pleased with my progress so far in building generic data access objects and having them work well against DBF and SQL Server data (which is a requirement).
>
>I have essentially wrapped ADO.Net objects with utility objects (one for DBF and one for SQL Server) that mimic things like SQLCONNECT(), SQLDISCONNECT, SQLEXEC(), etc. It has worked well up until I am trying to make parameterized queries. I got very spoiled by VFP's SQL Passthrough syntax sugar:
>
>INSERT INTO mytable VALUES (?var1, ?var2, ?var3)
>
>The "?" syntax saves all kinds of problems related to data types and such. Of course, that syntax comes at the price of not being data safe, etc.
>
>In .NET, I am quickly having to get used to the more-strict data typing. I like it, as it will save tons of run-time errors even if the code is a bit harder to knock out up front. But I DO want my SQL statements to be type-agnostic. So far, it looks like .NET is going to require me to set up parameters by declaring their type name, type, and size. One cannot simply add a parameter name and assign it...SqlParameter and OleDbParameter require data types as they are created.
>
>That doesn't make sense to me. If I change my data structure on the database backend from varchar(10) to varchar(15), I don't want to have to go lengthen my parameters throughout my code. I want a generic parameter type that I can assign a value to and have it pass through to the database (like the "?" does in VFP SPT). I'll send it right, so I don't need SQL Server or .NET being a bugger about it.
>
>I have been reading about frameworks, factory classes, interfaces, etc, but nothing seems straightforward. At this point it would be easier for me write a function that simply builds a SQL statement as a string instead of even using parameters. Let's face it: the bottom line on parameters is simply that they make it easier to pass various data types without worrying about single-quotes, {} for VFP dates, etc. There's no magic there, the VFP "?" just saves a lot of tedium.
>
>Can anyone tell me how to relieve that tedium in .NET as well? I just want to send straight SELECT, INSERT, UPDATE, and DELETE statements. That's what we have been using and will continue to use because they are easy, standard, and because we already have tons of statements written in VFP.
>
>Any help would be greatly appreciated!
>
>Thanks,
>JoeK
Alexandre Palma
Senior Application Architect
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform