Hi,
I want to write data to a table. The table does not exist yet by the time I want to open my Connection.
How my Connection string's going to look like.
I don't have to add the table name to my Connection string, do I ?
Thanks
Printable View
Hi,
I want to write data to a table. The table does not exist yet by the time I want to open my Connection.
How my Connection string's going to look like.
I don't have to add the table name to my Connection string, do I ?
Thanks
The connect string is used to connect to the database. You should connect to the database first.Then you use a command object to create the table you wanna to write data to.Now you can open the table and write data to it,Or you can finish this task via SQL statements.
You don't need to specify the table name at the time of connection. Use the following syntax to connect to a database.
private adoDB as new Connection
adoDB.Open "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=false;Data Source=MyPath\MyDBName.mdb
This will open any Database for you. Now to use any table at any time, use the following syntax.
Dim MySQL as string
MySQL="select whatever_fields from whatever_table where whatever_condition"
Dim adoRS as new RecordSet
adoRS.Open MySQL, adoDB, adOpenStatic, adLockReadOnly
I hope this will work for you.
Bye......
Hi,
Can you send me codes for that
Thanks in advance
You can establish the connection like this:
'Define the Variable
dim Conn as new ADODB.Connectiion
dim cmd as new ADDB.Command
'Establish the Connection
Conn.open "PROVIDER=MSDASQL;Driver=SQL Server;Server=SQLServer;UID=sa;PWD=;Database=SQLDatabase;"
'Execute a Command to create a table
'you should use your own table defination to replace the definations below
cmd.CommandText="Create Table TableName(col1 char(10) null, col2 char(10) null)"
cmd.execute
'delete these objects
set cmd=nothing
conn.close
set conn=nothing
Thanks for your help Hover!!!!!
U need not specify the table name only the database name is required this connection string is for SQL Server as the backend. if not SQL Server tell us which back end u r using
connecta$ = "Provider=sqloledb;Driver={SQL Server};Server=shab_server;db=<Your Database NAME>;uid=sa;pwd="
please get back to [email protected] or [email protected] for further clarifications
The Ultimate Solution Providers
Authors
Sriman & Jayaraman
Email : [email protected]
[email protected]
Hand Phone : +(6) 016 2237147 (Malaysia)