I have further questions. I would truly appreciate if you could take time to answer them.
1. I have successfuly retreive the value of "pass" filed from csv file. Now I also want the value from the "name" field. How?
Dim email As String = tx_email.Text Dim name As String
Dim password As String
Dim path As String = Server.MapPath(Request.ApplicationPath) & "\data\"
Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & path & "; Extended Properties='text; HDR=Yes; FMT=Delimited'")
Dim command As OleDbCommand = con.CreateCommand()
command.CommandText = "SELECT name, pass FROM wholesale.csv WHERE email = @email"
command.Parameters.AddWithValue("@email", email)
con.Open() name =
password = command.ExecuteScalar().ToString()
con.Close()
2. I want to use | character in seated of ,(comma) to separatre each filed in the csv file. The csv file looks as below
name | email | pass
Zuke Oshiro | info@msn.com | password01
Tom Black | info@yahoo.com | password02
I think I need to edit the following line.
Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & path & "; Extended Properties='text; HDR=Yes; FMT=Delimited'")
zuke01
Member
21 Points
41 Posts
Re: How to search for a value in a csv file and return another value.
Jul 04, 2008 08:15 PM|LINK
I have further questions. I would truly appreciate if you could take time to answer them.
1. I have successfuly retreive the value of "pass" filed from csv file. Now I also want the value from the "name" field. How?
Dim email As String = tx_email.Text
Dim name As String
Dim password As String
Dim path As String = Server.MapPath(Request.ApplicationPath) & "\data\"
Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & path & "; Extended Properties='text; HDR=Yes; FMT=Delimited'")
Dim command As OleDbCommand = con.CreateCommand()
command.CommandText = "SELECT name, pass FROM wholesale.csv WHERE email = @email"
command.Parameters.AddWithValue("@email", email)
con.Open()
name =
password = command.ExecuteScalar().ToString()
con.Close()
2. I want to use | character in seated of ,(comma) to separatre each filed in the csv file. The csv file looks as below
name | email | pass
Zuke Oshiro | info@msn.com | password01
Tom Black | info@yahoo.com | password02
I think I need to edit the following line.
Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & path & "; Extended Properties='text; HDR=Yes; FMT=Delimited'")
How?