Embed stored procedures?

  • Thread starter Thread starter Chris Williams
  • Start date Start date
C

Chris Williams

I've written some stored procedures that I want to use in my vb.net program.
I know how I can add them to SQL by entering the stored proc as a string and
then use the ExecuteNonQuery command to add them to the SQL server.
However, I was wondering if there was another way to embed them into my vb
project.

I see when I add the .sql file to the project that in the Build Action
options for the file, they are automatically marked as "content". Can I use
something in System.Reflection to enumerate these files, pull them out of
the compiled .exe and then add them the SQL (likely still using
ExecuteNonQuery)?

Thanks,

Chris
 
I see when I add the .sql file to the project that in the Build Action
options for the file, they are automatically marked as "content". Can I use
something in System.Reflection to enumerate these files, pull them out of
the compiled .exe and then add them the SQL (likely still using
ExecuteNonQuery)?

Change the build action to "Embedded Resource", then you can use code
similar to this post to pull the stored procs out:

http://tinyurl.com/nfc1
 
Back
Top