Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. ODBC, ADO

ODBC, ADO

Scheduled Pinned Locked Moved Visual Basic
databasesql-serversysadminquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kag
    wrote on last edited by
    #1

    Hi, I'd created a database using SQL Server. Then I've created ODBC in the control panel. I want to know :confused: how I can deal with ODBC in VB6. I've tried to use "Adodc" but I think it saves just one record. I’ve used this statement"Adodc.Recordset.AddNew" , but it saved the new record and deleted the old one. Also I want to be able to save whatever I want in the fields without using DataField property for TextBoxes. Or, I wonder if I could use Data Control with ODBC. I've used these statments: Data1.Connect = "DSN=DSNName" Data1.RecordSource = "My TableName" But seems that it needs to SET recordset. What should I use for it? Thanks.

    D 1 Reply Last reply
    0
    • K kag

      Hi, I'd created a database using SQL Server. Then I've created ODBC in the control panel. I want to know :confused: how I can deal with ODBC in VB6. I've tried to use "Adodc" but I think it saves just one record. I’ve used this statement"Adodc.Recordset.AddNew" , but it saved the new record and deleted the old one. Also I want to be able to save whatever I want in the fields without using DataField property for TextBoxes. Or, I wonder if I could use Data Control with ODBC. I've used these statments: Data1.Connect = "DSN=DSNName" Data1.RecordSource = "My TableName" But seems that it needs to SET recordset. What should I use for it? Thanks.

      D Offline
      D Offline
      David Wengier
      wrote on last edited by
      #2

      If you dont want to use the DataField and DataMember properties, it is best to just use ADO code.

      Dim conn As ADODB.Connection
      Dim rs as ADODB.Recordset
      Set conn = new Connection
      conn.Open "DSN=DSNName"
      set rs = conn.Execute("SELECT * FROM table")

      etc. etc. -- David Wengier Sonork ID: 100.14177 - Ch00k

      K 1 Reply Last reply
      0
      • D David Wengier

        If you dont want to use the DataField and DataMember properties, it is best to just use ADO code.

        Dim conn As ADODB.Connection
        Dim rs as ADODB.Recordset
        Set conn = new Connection
        conn.Open "DSN=DSNName"
        set rs = conn.Execute("SELECT * FROM table")

        etc. etc. -- David Wengier Sonork ID: 100.14177 - Ch00k

        K Offline
        K Offline
        kag
        wrote on last edited by
        #3

        Thanks:rose: for the replaying but I want to Add , Delete or Edit the Data :confused: . When I used "rs.addnew" it gives me an error.

        D 1 Reply Last reply
        0
        • K kag

          Thanks:rose: for the replaying but I want to Add , Delete or Edit the Data :confused: . When I used "rs.addnew" it gives me an error.

          D Offline
          D Offline
          David Wengier
          wrote on last edited by
          #4

          You can add, update and delete using SQL statements as I have said. If you notice the error message would probably have said something about having the wrong cursor type to use AddNew. Therefore, open the recordset using a different cursor. Try Dynamic. -- David Wengier Sonork ID: 100.14177 - Ch00k

          K 1 Reply Last reply
          0
          • D David Wengier

            You can add, update and delete using SQL statements as I have said. If you notice the error message would probably have said something about having the wrong cursor type to use AddNew. Therefore, open the recordset using a different cursor. Try Dynamic. -- David Wengier Sonork ID: 100.14177 - Ch00k

            K Offline
            K Offline
            kag
            wrote on last edited by
            #5

            When I use "rs.AddNew" it gives me this error: The operation requested by the application is not supported by the provider". Also, I Wonder if I can use OpenDataBase & OpenRecordSet with ODBC. Thanks

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups