4

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?

Rowland Shaw
  • 37,700
  • 14
  • 97
  • 166

4 Answers4

0
CREATE TABLE table1 (
field1 Integer(4),
field2 Character(10));
Oleg
  • 823
  • 6
  • 5
0

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.

DRapp
  • 47,638
  • 12
  • 72
  • 142
  • No, i can't. I tested that provider but Foxpro 2.6 Dos can't recognize the produced file with the Microsoft Visual Foxpro OleDB Provider. –  Apr 29 '13 at 17:28
0

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))
Jerry
  • 6,357
  • 8
  • 35
  • 50
  • No, i can't. I tested that provider but Foxpro 2.6 Dos can't recognize the produced file with the Microsoft Visual Foxpro OleDB Provider. –  Apr 29 '13 at 17:29
  • If the table needs to be Foxpro DOS 2.6 compatibile, then Numeric() is the way to go. Try: CREATE TABLE MyTableName (MyNumField Numeric(6), MyCharField C(10)) – Jerry Apr 29 '13 at 18:03
0

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) )"
Ori Lentz
  • 3,668
  • 6
  • 22
  • 28