I have a windows application
which needs to run a sqlfile
stored in the application itself.
I need to know how to store Sql file
in the application itself and then run it.
I know how to run a sql file stored in windows explorer but this is unknown to me.
If there is any particular way to do this, do tell me. If it's not possible then there might be any alternative to this.
Help appreciated.
Is there any proper way to store a sql file in C# windows application and run it at particular time?
Asked
Active
Viewed 196 times
1

Veer
- 1,575
- 3
- 16
- 40
-
1Keep your .sql file in the .resx file, and you can access it as string from `ResxClass.SqlFileName`. It can be used to do parameterized query. I usually do this to avoid stored procedure at database. – Fendy May 02 '13 at 06:25
-
If you know how to run a SQL statement from a file stored in the filesystem (I wonder how you manage to store it in windows explorer ^_^) then you can probably do the same thing for `[ApplicationPath]\YourSqlFile.sql` – Corak May 02 '13 at 06:26
-
@Fendy Can it be kept in seperate folder, lets say `db`. and from there it can be executed. – Veer May 02 '13 at 06:37
-
It should be able to keep it in separate folder. However, I haven't tried it in web environment so I cannot be sure whether it can work under web environment. It is compiled though, so you cannot change the content without compiling. – Fendy May 02 '13 at 07:04
-
@Fendy I am storing the sql file in Resources.resx. Now I dont want to access a string instead as file. I am not able to get its location. – Veer May 02 '13 at 07:17
-
@VeerB.Singh I don't get what you need. SQL file usually accessed for its string. If you need to modify the `.sql` on the run and access it as a file, you can use System.IO instead. Maybe you need to provide the real use case in your question. – Fendy May 02 '13 at 07:25
-
@Fendy ResxClass.Veer.sql is not getting the required string.Instead generating a error `The name 'ResxClass' does not exist in the current context` – Veer May 02 '13 at 07:58
-
Maybe this stack overflow question can help you? http://stackoverflow.com/questions/3534655/how-do-i-publish-deploy-an-mvc-project-with-resx-resources – Fendy May 02 '13 at 08:05