|
-
Aug 18th, 2000, 10:37 AM
#1
Thread Starter
Member
Two very simple questions: Is it possible to create an Access database on the fly using ADO? If so, how?
Second: How does access handle string fields? If I create a field of 20 characters, and I have 3 characters of data, does it store spaces or lock up the memory for 20 characters or does it chop the field down to only the amount of space necessary?
Thanks,
Chuck
To err is human, but to apologize frequently is embarassing.
-
Aug 18th, 2000, 02:08 PM
#2
Frenzied Member
Item 1, yes. Tom Clunie has posted this in the past, a search of this forum should get you what you want.
Item 2. There is no varchar in Access, it's going to use the size you specify.
-
Aug 18th, 2000, 05:47 PM
#3
Regarding item #2, I beg to differ. In Access, when you declare a field as Text, the length you declare is the MAXIMUM number of characters that can be stored in the field - but it is a variable-length field and will only store the number of characters necessary. This is true when you design a table in the Access UI or use a SQL CREATE TABLE statement, such as:
dbMyDB.Execute "CREATE TABLE MyTable (MyField TEXT(20))"
Here's an obscure bit of trivia. The ONLY way you can create a FIXED length character field in Access is with SQL and declare a field as CHAR rather than TEXT:
dbMyDB.Execute "CREATE TABLE MyTable (MyField CHAR(20))"
"It's cold gin time again ..."
Check out my website here.
-
Aug 21st, 2000, 08:36 AM
#4
Thread Starter
Member
Thanx for your help JHausmann and BruceG. I'm posting this for anyone following this line. This is Clunietp's code for creating a DB in ADO. Thanx to Clunietp for posting it in the first place.
-Chuck
********************************************************
Clunietp
Guru
Registered: Oct 1999
Posts: 1877
Create a database using ADO:
code:
'uses ADO 2.x for DDL and security
Dim strConnectionStringOfNewDB As String
Dim objCat As ADOX.Catalog
'instantiate catalog object
Set objCat = New ADOX.Catalog
'connection string of new db -- includes driver/db type and location
strConnectionStringOfNewDB = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\NewDB.mdb"
'create it
objCat.Create strConnectionStringOfNewDB
'cleanup
Set objCat = Nothing
To err is human, but to apologize frequently is embarassing.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|