CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2000
    Posts
    13

    Cerating Table using SQL OLEDB.DLL

    Hi Friends,
    Can anybody help me to create tables using SQL DMO from VB with Primary Key and all database objects.



  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Cerating Table using SQL OLEDB.DLL

    here is a sample that uses SQLOLE. The methods are the same in SQLDMO.
    Just replace SQLOLE with SQLDMO.
    Tested with SQLServer 6.5 on NT 4 VB 6

    Dim s as SQLOLE.SQLServer
    set s = new SQLOLE.SQLServer
    s.Connect "yourserver", "sa", ""
    Dim t as new SQLOLE.Table
    Dim col as new SQLOLE.Column
    col.Name = "test"
    col.Datatype = "varchar"
    col.Length = 10
    col.AllowNulls = false
    t.Columns.Add col
    set col = new SQLOLE.Column
    col.Name = "test2"
    col.Datatype = "varchar"
    col.Length = 5
    col.AllowNulls = true
    t.Columns.Add col
    t.Name = "mytesttable"
    Dim k as new SQLOLE.Key
    k.Clustered = true
    k.Type = SQLOLEKey_Primary
    k.KeyColumns.Add "test"
    t.Keys.Add k
    't.PrimaryKey = "test"
    s.Databases("einzeltest").Tables.Add t
    s.Disconnect





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