CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 1999
    Posts
    14

    ADO Connection String

    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


  2. #2
    Join Date
    Aug 1999
    Posts
    7

    Re: ADO Connection String

    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.


  3. #3
    Join Date
    Aug 1999
    Location
    Bahrain
    Posts
    13

    Re: ADO Connection String

    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......


  4. #4
    Join Date
    Aug 1999
    Posts
    14

    Re: ADO Connection String

    Hi,
    Can you send me codes for that

    Thanks in advance


  5. #5
    Join Date
    Aug 1999
    Posts
    7

    Re: ADO Connection String

    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





  6. #6
    Join Date
    Aug 1999
    Posts
    14

    Re: ADO Connection String

    Thanks for your help Hover!!!!!


  7. #7

    Re: ADO Connection String

    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)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured