Click to See Complete Forum and Search --> : SQL CREATE TABLE and access db


leeshadmi
November 16th, 2006, 04:59 AM
Hi
I need to create a table that one of it's field is string but i need it to be more then 255 size.
In access there is a type called Memo is there any way to create the field using this type? if yes can any one give me the right word like (TEXT (255))

Here is what i have now:
CREATE TABLE TB_2 (RecID Number Not NULL PRIMARY KEY, NoteData Text (250));

Thanks

HanneSThEGreaT
November 16th, 2006, 05:57 AM
[ Moved ]

jmcilhinney
November 16th, 2006, 05:58 AM
If the type of the column is Memo then surely you need to specify Memo as the type in your SQL statement.

leeshadmi
November 16th, 2006, 07:28 AM
Ok but how?
When i try this:
CREATE TABLE TB_2 (RecID Number Not NULL PRIMARY KEY, NoteData Memo);
Its not working.

jmcilhinney
November 16th, 2006, 07:26 PM
I just executed the following code and it worked exactly as you'd expect:Dim con As New OleDbConnection("File Name = E:\Documents\John\db1.udl")

Try
con.Open()

Dim cmd As New OleDbCommand("CREATE TABLE Table1 (ID Number NOT NULL PRIMARY KEY, Description Memo)", con)

cmd.ExecuteNonQuery()

MessageBox.Show("Success")
Catch ex As Exception
MessageBox.Show(ex.ToString())
Finally
con.Close()
End TryThe table was created successfully with the appropriate columns.

If you want people to tell you what you're doing wrong you first need to describe what you're doing and what happens when you do it. That means providing either the actual code or a very good description of it, then any eror messages or unexpected occurrences when it's executed

That's VB code. This thread has been moved and I can't remember now whether you were using VB or C#. The idea is fairly obvious though, so if you're using C# it should be pretty easy to convert.

Mustang97
November 26th, 2006, 11:37 PM
This thread has helped me with 1 of 2 things I have been trying to figure out. I finally got the primary key set but instead of the ID set to number how do you set it to autonumber? It dont give me an error it just wont create the table.

Using VB.NET 2003

fld_id number NOT NULL PRIMARY KEY, works

fld_id autonumber NOT NULL PRIMARY KEY, wont work


Mustang97

cjard
November 27th, 2006, 06:54 AM
Access gives fluffy names to things in the designer. The names of these things are different in jet SQL. E.g. its not called AUTONUMBER in sql, its called IDENTITY or soemthing like that..


Try googling for JET DDL


JET = the database engine
DDL = data definitiion language = SQL statements that set up tables, views, etc

Mustang97
November 27th, 2006, 07:19 AM
Sweet. Thanks rather easy once you know what its call to search for. Future reff to anyone its rather simplely named :/ counter and I been banging my head trying to figure out wth its called.


Thanks for your reply.

Mustang97