Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 26th, 2005, 04:21 PM
Registered User
 
Join Date: Jul 2004
Location: Largo, FL, USA.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Text file import to data grid missing some values

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.CloseConne ction);
        DataGrid1.DataBind();

        myConnection.Close();
    }

</script>
<html>
<head>
</head>
<body style="FONT-FAMILY: arial">
    <h2>Simple Data Report
    </h2>

    <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
  #2 (permalink)  
Old April 3rd, 2006, 11:58 AM
Registered User
 
Join Date: Apr 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

DId you ever find a solution to this problem? I am having the same problem myself.

Thanks,
ZAID

Quote:
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.CloseConne ction);
        DataGrid1.DataBind();

        myConnection.Close();
    }

</script>
<html>
<head>
</head>
<body style="FONT-FAMILY: arial">
    <h2>Simple Data Report
    </h2>

    <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



  #3 (permalink)  
Old April 14th, 2006, 10:42 AM
Registered User
 
Join Date: Apr 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to dkirwan
Default

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.

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Import from Excel sheet to a text file zone Excel VBA 1 July 26th, 2007 10:34 AM
How can i import a local text file into a jsp file ravibabu Java GUI 1 April 25th, 2007 04:05 AM
How to import data from text file? starnet SQL Server 2000 1 September 18th, 2006 06:56 AM
Apply Custom template & import data from text file shampabera Excel VBA 2 August 8th, 2005 07:41 AM
import data from text file to excel(VBA) topr Excel VBA 2 August 26th, 2004 11:36 PM



All times are GMT -4. The time now is 09:41 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.