jgordin
asked on
C# wrapper for sql statements (similar to csh on unix that runs sql commands)
how to run sql statements using C# as a wrapper
ASKER
i need a solution that would resemble running sql command in csh (unix).
uhhh could you explain a bit more what you want exactly? :?
ASKER
1. i have a bunch sql statement
2. i need to run those statement in batch
3. one can do it chs c -shell) script on unix. I would like to do that in #C .net application. that is, a shell/wrapper that would execute my sql statements.
2. i need to run those statement in batch
3. one can do it chs c -shell) script on unix. I would like to do that in #C .net application. that is, a shell/wrapper that would execute my sql statements.
Well.. most SQL servers have command line clients I guess..
what server are you targeting? MS SQL Server?
what server are you targeting? MS SQL Server?
Since I haven't used the C Shell with Unix, what kind of syntax/commands does it allow? What do you need?
Bob
Bob
ASKER
C shell in unix allows to create *.csh file when one can specify sql commands:
file.csh:
isql -S ....
select * from test ...
I need to be able to do similar things in c# .net.
file.csh:
isql -S ....
select * from test ...
I need to be able to do similar things in c# .net.
What database type are you using?
Bob
Bob
If you have SQL Server, there is the osql command line processor:
osql -ddatabase -sserver -E -q"Select * From Table"
Bob
osql -ddatabase -sserver -E -q"Select * From Table"
Bob
ASKER
microsoft sql server. i need to have a wrapper that allows to run sql statements that are in *.xml or *.txt file. i also need to pass parameters to sql commands.
ASKER
any solution to this problem? thanks.
You could create a Console application that takes the arguments that you need, an runs the query and outputs the results.
Bob
Bob
ASKER
what is a console application?
here is what i need:
file1:
select * from test whe test_col = parameter(passed from file2)
update
update
file2:
execute file1 statements
here is what i need:
file1:
select * from test whe test_col = parameter(passed from file2)
update
update
file2:
execute file1 statements
File | New Project | C# | Console application
Bob
Bob
ASKER
how do i execute and pass parameters to a file with sql statements? thanks.
The main method in the Program.cs file looks like this:
static void Main(string[] args)
{
}
'args' is a string array of arguments that you can pass to the executable.
Example:
SqlQuery -sserver -ddatabase -iinputfile
Bob
static void Main(string[] args)
{
}
'args' is a string array of arguments that you can pass to the executable.
Example:
SqlQuery -sserver -ddatabase -iinputfile
Bob
ASKER
i need to execute a whole bunch of statements.
select * from test where test_col = "parameter"
update
select
etc..
select * from test where test_col = "parameter"
update
select
etc..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.codeproject.com/cs/database/SqlWrapper.asp