I want to build SQL query and save it to the text file. I need it to execute that query later. DbCommand
can create valid SQL query, but how can I take the string representation of the query to save to file? Or maybe there is another way to build SQL and save it to string?
Asked
Active
Viewed 97 times
-2

gustav
- 119
- 13
-
How about stored procedures? – garry man Dec 15 '18 at 10:38
-
Writing strings to a file has many options in .NET, StreamWriter, File.WriteAllLines, File.WriteAllText, etc. Can you clarify exactly what it is you're having problems with? – Lasse V. Karlsen Dec 15 '18 at 12:22
1 Answers
1
while debugging, you can right click on the property and select "Add Watch".
Now in you watch window you see the Name & Value. Copy the Vlaue to clipboard and you can use it to your liking.

Aldert
- 4,209
- 1
- 9
- 23
-
-
Then in code store the SQL query to the file, link: https://stackoverflow.com/questions/6153074/how-do-i-write-data-to-a-text-file-in-c – Aldert Dec 15 '18 at 11:25