Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a sql file. i want to read the file replace some words in it and then execute in SQL server. Here is an example.

SQL
INSERT INTO [destinationDBName].dbo.[devicemake](id,name,isactive,provid)
(select id,Make,1,ID from [sourceDBName].dbo.DeviceMake)


THe file may contain 10 queries like this and i want to read each query and execute them . Before executing i want to replace [destinationDBName] with values i provide in GUI , same is the case with [sourceDBName] .. Pls help
Posted

 
Share this answer
 
Comments
Arjun Menon U.K 25-Apr-13 23:43pm    
string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
string path = System.IO.Path.GetDirectoryName(Application.ExecutablePath);

what is the difference? the first one returns the assembly path and second one exe of the applicatiion? All i want to do is get a file content from a path. The file is in the bin folder of apps so i thnk second one is correct.. Pls Correct if i am wrong.. Thanks in advance
string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);

string queries = File.ReadAllText(path);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900