4
votes

I want to create a table (.DBF file) with an Integer(4) field using Microsoft Jet dBase Provider. There is my code :

    Dim conn As New OleDb.OleDbConnection
    Dim comm As New OleDb.OleDbCommand
    conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DBFSamples;Extended Properties=dBASE 5.0;"
    conn.Open()
    comm.Connection = conn
    comm.CommandType = CommandType.Text
    'First Solution
    comm.CommandText = "Create table Test8(FirstName Integer,LastName Char(50) )"
    'Second Solution
    'comm.CommandText = "Create table Test10(FirstName Numeric(4,0),LastName Char(50) )"
    comm.ExecuteNonQuery()
    conn.Close()
    MessageBox.Show("OK")

This code creates the FirstName field Numeric(20,5) with the First Solution and Numeric(20,0) with the Second Solution. Is there another solution?

4

4 Answers

0
votes
CREATE TABLE table1 (
field1 Integer(4),
field2 Character(10));
0
votes

I don't know if you can do it with Jet, but you should be able to do with Microsoft Visual Foxpro OleDB Provider instead.

0
votes

Can you use a Visual Foxpro table? If so, use this syntax to create a table with an Integer column and Character column:

 CREATE TABLE MyTableName (MyIntField I, MyCharField C(10))
0
votes

Use the following conection:

connectionString = @"Provider=vfpoledb.1;Data Source=" + path + ";Collating Sequence=machine;";

Download Microsoft OLE DB Provider and create your query

comm.CommandText = "Create table Test10(FirstName Numeric(4,0),LastName Char(50) )"