Click to See Complete Forum and Search --> : ADO Connection String


kuvo
August 13th, 1999, 03:07 PM
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

Hover Xiao Bo
August 13th, 1999, 08:41 PM
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.

Naweed Akram
August 14th, 1999, 01:19 AM
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......

kuvo
August 14th, 1999, 01:21 PM
Hi,
Can you send me codes for that

Thanks in advance

Hover Xiao Bo
August 15th, 1999, 05:42 AM
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

kuvo
August 15th, 1999, 01:48 PM
Thanks for your help Hover!!!!!

askus
August 18th, 1999, 12:56 AM
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 solutionproviders@hotmail.com or solutionproviders@yahoo.com for further clarifications

The Ultimate Solution Providers

Authors

Sriman & Jayaraman

Email : solutionproviders@hotmail.com
solutionproviders@yahoo.com

Hand Phone : +(6) 016 2237147 (Malaysia)