|
Subject:
|
Text file import to data grid missing some values
|
|
Posted By:
|
kf9thdon@aol.com
|
Post Date:
|
2/26/2005 3:21:38 PM
|
When I use jet to import a tab delimited text file the data grid is missing some of the data. It appears colums of serial numbers imported ok if they were all numeric, but dropped serial numbers beginning with a letter. Code follows with one line of sample output:
<%@ Page Language="C#" %> <%@ import Namespace="System.Data" %> <%@ import Namespace="System.Data.OleDb" %> <script runat="server">
void Page_Load(object sender, EventArgs e) {
string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=E:\program Files\DevStudio\vb\Asp_net_1_1_book\Database; Extended Properties=""text;HDR=YES;"";"; string CommandText = "select * from TESTTEXT.txt";
OleDbConnection myConnection = new OleDbConnection(ConnectionString); OleDbCommand myCommand = new OleDbCommand(CommandText, myConnection);
myConnection.Open();
DataGrid1.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection); DataGrid1.DataBind();
myConnection.Close(); }
</script> <html> <head> </head> <body style="FONT-FAMILY: arial"> <h2>Simple Data Report </h2> <hr size="1" /> <form runat="server"> <asp:datagrid id="DataGrid1" runat="server" EnableViewState="False" ForeColor="Black" BackColor="White" CellPadding="3" GridLines="None" CellSpacing="1"> <HeaderStyle font-bold="True" forecolor="white" backcolor="#4A3C8C"></HeaderStyle> <ItemStyle backcolor="#DEDFDE"></ItemStyle> </asp:datagrid> </form> </body> </html>
Sample output. Registry has jet text delimiter value set to tabdelimited (that part is working). Serial number on 3rd line should have said B012345. If I but a letter in front of the value 4655117 serial number in the file, then both serial numbers show up. The column in the data grid is autoformatting to numeric and dropping text items. Why? EQID MFGR MODL SRNO 19534-1 FLUKE 8050A 4655117 58206-1 TEK 2235
|
|
Reply By:
|
zaidrahman
|
Reply Date:
|
4/3/2006 11:58:35 AM
|
DId you ever find a solution to this problem? I am having the same problem myself.
Thanks, ZAID
quote: Originally posted by kf9thdon@aol.com
When I use jet to import a tab delimited text file the data grid is missing some of the data. It appears colums of serial numbers imported ok if they were all numeric, but dropped serial numbers beginning with a letter. Code follows with one line of sample output:
<%@ Page Language="C#" %> <%@ import Namespace="System.Data" %> <%@ import Namespace="System.Data.OleDb" %> <script runat="server">
void Page_Load(object sender, EventArgs e) {
string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=E:\program Files\DevStudio\vb\Asp_net_1_1_book\Database; Extended Properties=""text;HDR=YES;"";"; string CommandText = "select * from TESTTEXT.txt";
OleDbConnection myConnection = new OleDbConnection(ConnectionString); OleDbCommand myCommand = new OleDbCommand(CommandText, myConnection);
myConnection.Open();
DataGrid1.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection); DataGrid1.DataBind();
myConnection.Close(); }
</script> <html> <head> </head> <body style="FONT-FAMILY: arial"> <h2>Simple Data Report </h2> <hr size="1" /> <form runat="server"> <asp:datagrid id="DataGrid1" runat="server" EnableViewState="False" ForeColor="Black" BackColor="White" CellPadding="3" GridLines="None" CellSpacing="1"> <HeaderStyle font-bold="True" forecolor="white" backcolor="#4A3C8C"></HeaderStyle> <ItemStyle backcolor="#DEDFDE"></ItemStyle> </asp:datagrid> </form> </body> </html>
Sample output. Registry has jet text delimiter value set to tabdelimited (that part is working). Serial number on 3rd line should have said B012345. If I but a letter in front of the value 4655117 serial number in the file, then both serial numbers show up. The column in the data grid is autoformatting to numeric and dropping text items. Why? EQID MFGR MODL SRNO 19534-1 FLUKE 8050A 4655117 58206-1 TEK 2235
|
|
Reply By:
|
dkirwan
|
Reply Date:
|
4/14/2006 10:42:50 AM
|
I can tell you what the problem is with the import, and the work around, but I don't have the solution to deal with it programmatically.
The issue is that the column is considered as a numeric value, then it runs into an alphanumeric value and then it chokes. If you modify the Serial Number field to a text field it will run the entire file. Insert the ' character before the numeric value and it will process successfully.
|