Click here to Skip to main content
15,920,005 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I used the below code to create a .DBF file and filling it, everything works fine. The problem is the name of the file is truncated to 8 characters max. Any idea why or how to make maintain the whole name?

C#
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+path+";Extended Properties=dBase IV";
          
OleDbConnection connection = new OleDbConnection(connectionString);
connection.Open();
cmd.CommandText = @"CREATE TABLE calendfull(
                                date1 datetime ,
                                day1 int ,
                                month1 int ,
                                year1 int ,
                                dow int ,
                                endmonth int  
                                )";

            cmd.ExecuteNonQuery();




  foreach (DataRow row in calend.Rows)
            {
                day = Convert.ToInt32(row["day"]);
                year = Convert.ToInt32(row["year"]);
                month = Convert.ToInt32(row["month"]);
                dow = Convert.ToInt32(row["dow"]);
                endmonth = Convert.ToInt32(row["endmonth"]);
                date1 = Convert.ToDateTime(row["date1"]);

                cmd.CommandText = @"insert into calendfull values ('" + date1 + "'," + day + "," + month + "," + year + "," + dow + "," + endmonth + ")";
                cmd.ExecuteNonQuery();
            }
Posted
Updated 2-Apr-13 1:11am
v4

1 solution

You're not showing us the ConnectionString but I suspect that the driver in the ConnectionString is causing this issue. Perhaps because the .DBF extension dates from the DOS era, the filenames are created in the old DOS 8.3 format.

Via a Google search, I found this article that talks about exactly that.

dBase ISAM driver filename limitation[^]

This article says that the MS Visual Foxpro OLE DB provider may solve the 8.3 filename issue. You'll have to try it to find out.
Answered DBF File Name Length issue (Microsoft visual fox pro)[^]

Microsoft OLE DB Provider for Visual FoxPro 9.0
[^]
 
Share this answer
 
v2
Comments
SalouaK 2-Apr-13 7:11am    
I updated my question and added the connection string to it
Mike Meinz 2-Apr-13 7:46am    
Thanks.

I improved Solution 1.

I found an article tha said that the Microsoft Visual Foxpro OLE DB provider may solve the 8.3 filename issue. You can try it and let us know if it works for you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900