Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C# replacement for VFP code
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01167122
Message ID:
01167170
Views:
18
Hi Folks, thanks for all your replies.

Really what I was after was a way to fasttrack into Dot Net. I have developed now a few very small apps (1 Web Forms and 1 Windows Forms) , both with a small amount of data handling, which I used Datasets and SqlDataSources.

I found myslef using about 8 lines of verbose code in c# (set connection string, set select command, set the dataadapter, set Dataset etc.) for commands in VFP that would have been maybe 2 (Use MyTable Alias 'MYT)

The main reason for the question was maybe there's a better, different way of doing things. I have a farly big app to convert/rewrite (300 forms) and I did not want to have to write 8 lines of code X 300 if I could maybe do this more economically.


Hi...best way to answer this - imagine that you'd rewrite your 8 lines for about 5 of your files/forms/whatever. How much would you be repeating?

Things like handling a connection string, opening a connection, filling a dataadapter, etc., are common things that you can put into a base data access component. For most of your custom data access, it might be a matter of either specifying the name of a stored proc [or sql command string], plus a set of parameters.

If so, you might want to think about building a simple data access retrieve function that takes two parameters.....the name of a stored proc [or SQL select string], plus a collection/arraylist of SQL parameters....the function would handle all the connection string stuff, create a command object using the first parameter, set the sqlparameters based on your arraylist, execute the command, and return the resulting dataset [or return any results from an INSERT/UPDATE statement]

Are you using vs2003 or vs2005? I can post a code sample that might help get you started, based on which version of .NET you're using.

When I was learning .NET, one of the things that helped me to build resuable components was just to project out how much code I'd be writing if I wasn't going to reuse any code - then the light bulb came on.


Kevin
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform