i have a db called HairDesign and it is protected with a password of 123456
now in this DB i have a table called BackArc
is there a wat to create with vb another field?
Attachment 130497
PassWord is 123456
tnx in advanced
salsa31
Printable View
i have a db called HairDesign and it is protected with a password of 123456
now in this DB i have a table called BackArc
is there a wat to create with vb another field?
Attachment 130497
PassWord is 123456
tnx in advanced
salsa31
Use the Alter Table method:
just execute it like any other SQL statement against the database.Code:Alter table [table name]
Add column [column name] [column type] [null|not null]
-tg
Hey
tg
can you give me a Start or something?Quote:
just execute it like any other SQL statement against the database.
do i need to Dim SomeThing?
It's jsut a SQL statement. Nothing more. Nothing less. I KNOW you know how to execute SQL statements, you've got plenty of posts were that's been discussed. There's nothing special about it except it will not return a recordset.
-tg
sry sir never done this beforeQuote:
Alter table [table name]
Add column [column name] [column type] [null|not null]
BTW the DB has a password 123456
this is the SQL i know
Code:StrSql = "Update PriceList set PriceStartTime ='0', PriceEndTime ='0'"
CN.Execute StrSql
If this is a Jet 4.0 (Jet OLEDB:Engine Type=5, a.k.a. "Access 2000/2002/2003 format") database then there are two types of "passwords."
One is the simple caveman "database password" for share-level security and the other is a "user password" that varies by user when you are using proper Jet user & group role-based security.
If you are using share-based security then it is merely a matter of supplying that password when you connect. The Connection Property is named "Jet OLEDB:Database Password" and you can set this in the connection string or separately via the Connection.Properties collection.
The same is true for role-based security, but you have two properties "User ID" and "Password" to set.
Once you have a connection opened with sufficient permissions you can add a column/field to the table either via ADOX or via Jet SQL DDL commands.
hey sir this is what i use
Code:Public Sub DataBaseConnectionSystem()
On Error GoTo ErrMsg
Set CN = New ADODB.Connection
StrSql = "Provider=Microsoft.Jet.OLEDB.4.0;"
StrSql = StrSql & "Data Source=" & App.Path & "\HairDesign.mdb;"
StrSql = StrSql & "Jet OLEDB:Database Password=123456"
CN.ConnectionString = StrSql
CN.Open
ErrMsg:
End If
You've already opened your database....simply do what tg said in post #2....simple.
hey sami i dont know what to do sry:confused:
Why do you always insist on making this harder than it needs to be? I know you know how to execute a SQL statement. The forums are littered with your posts regarding SQL commands... This is no different. A SQL statement is a SQL statement... you create a command object, set the command text on it, then execute it... plain and simple. There's no magic to it.
And with that I'm done with this thread.
-tg
Instead of just giving you the code, please look at this tutorial...it tells you EXACTLY how do to what you want to do.
http://www.vb6.us/tutorials/access-sql
Sammi
i know yes but this is diffrentQuote:
Why do you always insist on making this harder than it needs to be? I know you know how to execute a SQL statement
i just want a starter thats itQuote:
Instead of just giving you the code, please look at this tutorial...it tells you EXACTLY how do to what you want to do.
what is this?Quote:
Alter table [table name]
Add column [column name] [column type] [null|not null]
alter table?
i dont understand Tg i am not playing around
just asking how to do this thats all why is it so hard to help me?
Alter table is one of many sql statements that can be used
What you have been shown is clear and simple and while you may not have did this exact thing before it is the same as what you have done 1000 times only the text on the sql statement is different.
Alter means to changeCode:CN.Execute SQLStatement
All you have to do is plug in the proper values for you table name, column name and such then execute it just like if it was an update query
you mean like this sir?Quote:
All you have to do is plug in the proper values for you table name, column name and such then execute it just like if it was an update query
Code:Dim StrSql As String
StrSql = "Update Alter table [BackArc] Add [Remarks] [Memo]"
CN.Execute StrSql
Yes and no. Yes you use execute as you have been told a few times already. No you do not add update into the query.
You added Update into the query and that does not go there.
You were shown what the sql statement should look like and there was no Update any where in any of that.
I said you execute just like you would an update query not that you should add update into it.
To execute any query you use execute, It doesn't matter it it is a drop statement, an alter statement or the ones you are more used to like update, delete, insert. They are all sql statements and they are all executed the same way the only thing that is different is the actual text of the statement.
forget it sir i dont understand i just dontCode:CN.Execute = "Alter table [BackArc] Add [Remarks] [Memo]"
you were so close with:
Code:Dim StrSql As String
StrSql = "Update Alter table [BackArc] Add [Remarks] [Memo]"
CN.Execute StrSql
Now, look at this EXAMPLE (IN THE LINK I SHOWED YOU IN #11):
can you take it from here? (Wish you had studied that tutorial!)Code:StrSql = "ALTER TABLE Customers ADD COLUMN CustName TEXT 25
Make it short.
After defining the password in your 'CN' connection string Database Password=123456
Build your query:
Execute it:Code:StrSql = "Alter Table [BackArc] Add Column [Field1] Text"
Done.Code:CN.Execute StrSql
More fun to read information on table altering can be found here: http://www.w3schools.com/sql/sql_alter.asp
hey stum what about the Db HairDesign?
i dont see it in the query
only the table
tnx for your help amigosCode:StrSql = "Alter Table BackArc Add Column Field1 Memo"
CN.Execute StrSql
Why would you name a field, "Field1"? Because it is a Memo field, maybe something like "Remarks" would be more suitable.
Too bad stum showed you....was hoping you'd get the answer from the link (post#11)...you learn more by researching than simply taking others' code...