1.I've created code that reads in a text file from a particular format and creates a SQL server database. I would like to encapsulate this code in a method. I would like to pass a file name into this method as a parameter which would be used to define a stream reader object file dynamically:
StreamReader
tr = File.OpenText("C://My Documents//filename.txt");
Does anyone know how to do this?
2. In created variables from my text files, some of the values are missing which I would like to convert to null values in SQL SERVER. How can I do this?
Thanks
Craig20 reputationPosted May 29, 2007, 6:06 AM EDT
Question 1)
I can pass in the filename verbatim using an @
string
filestring = @"C://My Documents//cexercises//labtest1.txt";I can pass this as an argument in the method:
public
void dbrun(string sql90input, string sql00input, string filestringput)I then can use the string in the file.opentext method of the streamreader class.
StreamReader
tr = File.OpenText(filestringput);A simple solution!
--------------
Using this approach, I can pass in different files to read in my method.
Mahesh ChandRank #1 · 393.3K reputationPosted May 29, 2007, 8:31 AM EDT
Craig20 reputationPosted May 29, 2007, 12:30 PM EDT
Thanks,
I'm new to SQL SERVER
Jan MontanoRank #1,295 · 1.3K reputationPosted May 29, 2007, 10:09 PM EDT
Craig20 reputationPosted Jun 4, 2007, 5:10 AM EDT
Thanks
Jan MontanoRank #1,295 · 1.3K reputationPosted Jun 6, 2007, 3:04 AM EDT
http://www.c-sharpcorner.com/UploadFile/sd_patel/EnterNullValuesForDateTime11222005015742AM/EnterNullValuesForDateTime.aspx