I have a tab delimited txt file with 6 million records.
There are 290 unique identifiers in this file so what I did was import the entire thing into SQL.
I am now trying to write a program in vb.net that will first run a query to gain all 290 unique identifiers, and then for each identifier it will query for all rows. I would like to save this data to a file named after the unique identifier.
Below is the code that I have so far, but I am unsure what code I need to use to save the information - any examples would be great!
Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim db_connection As SqlConnection Dim db_command, db_command2 As SqlCommand Dim datareader As SqlDataReader Dim var1, var2, filename As String 'Begin populate dropdownlist db_connection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionStringMerrillDataImport")) db_connection.Open() db_command = New SqlCommand("select DISTINCT [Column 2], [Column 3] from PIA_Holdings_Records_data_JanToJune order by [Column 2], [Column 3]", db_connection) datareader = db_command.ExecuteReader() While datareader.Read var1 = datareader.GetString(0) var2 = datareader.GetString(1) filename = var1 & var2 db_command2 = New SqlCommand("select * from PIA_Holdings_Records_data_JanToJune WHERE [Column 2] = '" & var1 & "'[Column 3] = '" & var2 & "'", db_connection) End While datareader.Close()
Sooo... It appears I have all the code needed to grab the information - what I need to do is take all the information in db_command2 and save it to a tab delimited text file.... Please help!