Howto access data within .NET SQL function?
Posted on 2007-04-03
I'm trying to learn Visual Studio SQL Projects and have managed to create a project, connect to a database, create a UDF and the associated test script. My question has to do with actually accessing the data. How?
What's the best way to access data? Currently I'm creating a SQLConnection, but this requires a connection string that only the calling application knows. Since the project is built and deployed against a database using Windows authentication why do I need a connection string in the first place? What if we deploy the assembly to another database, I don't want to hardcode the connection string. There should be a default connect using the credentials given at deployment time setting shouldn't there?
Additionally I'm going to need to know how to create a temp table and cursor to iterate, or in C# iterate through a recordset, is there anywhere out there where sample C# code in SQL Projects has been collected?
This seems like it's way harder than it should be.