CSV Import into gridview problem
Hi
I posted this in the ASP forums but think its more of a vb question so sorry for the repost:
I have an app that will load info from a csv into a gridview. Everything works properly except for one column. It is only displaying fields with numeric values. All of the alpha-numeric cells are being left blank. I have looked at the csv and it is properly formatted and the other columns have alpha-numeric as well and are being pulled in properly.
Here is a snippet of the code that populates the gridview. Any help would be most appreciated.
Code:
Dim savePath As String = "\\Depts\"
Dim Conn As System.Data.Odbc.OdbcConnection
Dim dt As New System.Data.DataTable
Dim da As System.Data.Odbc.OdbcDataAdapter
Dim strConnstr, strImportfolder, strFilename As String
strFilename = FileUpload1.FileName
'this is the csv file to be imported
strConnstr = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + savePath + ";"
Conn = New System.Data.Odbc.OdbcConnection(strConnstr)
da = New System.Data.Odbc.OdbcDataAdapter("SELECT Site, Line , Item, Date FROM [" + strFilename + "]", Conn)
da.Fill(dt)
Session("Import") = dt
GridView1.DataSource = Session("Import")
GridView1.DataBind()
The Item column is the one that is coming in incorrectly.
Re: CSV Import into gridview problem
I found that the majority of cells need to be alpha-numeric. That is odd to me. Is there anything I can do to the select statement to tell it that is not numeric?
Re: CSV Import into gridview problem
I have tried doing "SELECT CStr(Item)......."
but now getting an "invalid use of null" when i fill the da
Re: CSV Import into gridview problem
Strange, it is making the alpha-numeric cells null before evaluating them against the Cstr() function. I am stumped
Re: CSV Import into gridview problem