Export list code - IncorrectFormat.
Posted: Tue 11 Jan 2005 15:15
Dear Sir,
I am testing with MySQL, and .NET 2003 to export few records in text format with pipe “|” delimiter. But, unable to make it work. Any help or comments will be greatly appreciated.
VB.NET error "An unhandled exception of type 'System.FormatException' occurred in corelab.mysql.dill
Additional information: IncorrectFormat."
Below is the code for your examination:
Private Sub Download_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Download.Click
Dim MyConnString As String = "User Id=testUser;Host=localhost;Database=main;Password=st9041%SSpdW;"
Dim mySelectQuery As String = "SELECT name,phone,fax,address,city,state,zip FROM main.person"
Dim myConnection As New MySqlConnection(MyConnString)
Dim myCommand As New MySqlCommand(mySelectQuery, myConnection)
myConnection.Open()
Dim myReader As MySqlDataReader = myCommand.ExecuteReader()
Dim saveDialog As New SaveFileDialog
Dim myResult As DialogResult
saveDialog.Filter = "Text File (*.txt) | *.txt|All files (*.*)|*.*"
myResult = saveDialog.ShowDialog
FileOpen(1, saveDialog.FileName, OpenMode.Output)
Try
While myReader.Read()
WriteLine(myReader.GetInt32(0).ToString() + ", " _
+ myReader.GetString(1))
End While
Finally
myReader.Close()
myConnection.Close()
End Try
FileClose(1)
If myResult = DialogResult.OK Then
MsgBox("Saving: " + saveDialog.FileName)
End If
End Sub
Please accept my apologies, if this is not the proper place to post this issue.
Thank you,
Sam
I am testing with MySQL, and .NET 2003 to export few records in text format with pipe “|” delimiter. But, unable to make it work. Any help or comments will be greatly appreciated.
VB.NET error "An unhandled exception of type 'System.FormatException' occurred in corelab.mysql.dill
Additional information: IncorrectFormat."
Below is the code for your examination:
Private Sub Download_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Download.Click
Dim MyConnString As String = "User Id=testUser;Host=localhost;Database=main;Password=st9041%SSpdW;"
Dim mySelectQuery As String = "SELECT name,phone,fax,address,city,state,zip FROM main.person"
Dim myConnection As New MySqlConnection(MyConnString)
Dim myCommand As New MySqlCommand(mySelectQuery, myConnection)
myConnection.Open()
Dim myReader As MySqlDataReader = myCommand.ExecuteReader()
Dim saveDialog As New SaveFileDialog
Dim myResult As DialogResult
saveDialog.Filter = "Text File (*.txt) | *.txt|All files (*.*)|*.*"
myResult = saveDialog.ShowDialog
FileOpen(1, saveDialog.FileName, OpenMode.Output)
Try
While myReader.Read()
WriteLine(myReader.GetInt32(0).ToString() + ", " _
+ myReader.GetString(1))
End While
Finally
myReader.Close()
myConnection.Close()
End Try
FileClose(1)
If myResult = DialogResult.OK Then
MsgBox("Saving: " + saveDialog.FileName)
End If
End Sub
Please accept my apologies, if this is not the proper place to post this issue.
Thank you,
Sam