|
-
August 5th, 2010, 07:26 PM
#2
Re: Change column’s properties values
Here's another approach...
Code:
Option Explicit
' Add a reference to Microsoft ActiveX Data Objects 2.x Library
' and Microsoft ADO Ext 2.x for DDL and Security
Private Sub Form_Load()
'=============================
Dim tbl As New ADOX.Table
Dim cat As New ADOX.Catalog
Dim adoConn As New ADODB.Connection
Dim strConString$
Dim sSQL$, strLine$
If Dir(App.Path & "\NewDB.mdb") = "" Then
sSQL = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & App.Path & "\NewDB.mdb;" & _
"Jet OLEDB:Engine Type=5"
cat.Create sSQL
tbl.Name = "Table1"
tbl.Columns.Append "Field1", adInteger
tbl.Keys.Append "PrimaryKey", adKeyPrimary, "Field1"
tbl.Columns.Append "Date", adDBTimeStamp
cat.Tables.Append tbl
Set cat = Nothing
Set tbl = Nothing
End If
strConString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& App.Path & "\NewDB.mdb;Persist Security Info=False"
adoConn.Open strConString
Dim x As Integer
x = 1
Open App.Path & "\test.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, strLine
If strLine <> "" Then
sSQL = "Insert Into Table1 (Field1,[Date]) Values (" & _
CInt(strLine) & ",#" & _
CDate(Now) & "#)"
' sSQL = "Insert Into Table1 (Field1) Values (" & Chr(34) & strLine & Chr(34) & ")"
Debug.Print sSQL
adoConn.Execute sSQL
End If
x = x + 1
Loop
Close #1
adoConn.Close
Set adoConn = Nothing
End Sub
Tags for this Thread
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
|