CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: ADO

  1. #1
    Join Date
    Aug 1999
    Posts
    45

    ADO

    Hi,

    I want to overwrite a table MyTable. I tried:

    cmd.CommandText = "Drop Table MyTable"
    --> All it does is delete all the data, but the table is still there

    Then I try create MyTable again
    cmd.CammandText = "Create MyTable col1 char(10) "
    ----> ERROR MyTable already exist ????



  2. #2

    Re: ADO

    We tried the following code in VB and having sqlserver 7.0 as backend , its working perfectly.
    Public MyConn As ADODB.Connection

    Set MyConn = New ADODB.Connection

    ConnStr = "Provider=sqloledb;Driver={SQL Server};Server=" & <Your ServerName> & ";Initial Catalog=" & <Your Database Name> & ";User ID=sa;password=;"

    MyConn.ConnectionString = ConnStr

    Dim cmd As New ADODB.Command

    Set cmd.ActiveConnection = MyConn
    cmd.CommandText = "Drop table MyTable"
    cmd.Execute

    cmd.CommandText = "create table MyTable(MyCol varchar(10))"
    cmd.Execute

    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