dcsimg
Results 1 to 11 of 11

Thread: [RESOLVED] VB6 + ADODC = Terrible headache! Please please please help me...!

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2010
    Posts
    40

    Resolved [RESOLVED] VB6 + ADODC = Terrible headache! Please please please help me...!

    Oh God this is KILLING ME!!

    First of all, please don't tell me I didn't bothered searching for an answer in other posts. I've spend 2 whole days seeing if my problem was already solved in other threads/posts.

    So please be gentle and try to help me.

    My problem is the following:
    * I'm using vb6, ADODC and DataGrid
    * I ALREADY have loaded in my form the ADODC (already and correctly linked to my database), the DataGrid (already and correctly linked to the ADODC) and some other TextBox linked as well with ADODC.
    * Everything is fine, it all works perfectly. NOW: I just want to give to my ADODC the simplest SQL instructions, and I don't know how, beacuse all the info I got from VBForums is regarding NEW Ado controls, (not previously loaded).

    Please, note that I already know what commands I want to send to ADODC, and I already know how to do it with new controls.
    I also know how to set the ADODC with a starting SQL instruction, via ADODC's Properties

    You may ask why I want to know this if I already know how to do it with new controls. It's because it's so easy to just set the ADODC from VB, not via code. I just put it in the place I want it, the size I want it, to select via browser... to link TextBoxes and it all works so neat, so automatically... Come on! It has to be a simple way, something like:
    ADODC1.RecordSet.DO SQLInstr

    Thank you, and please excuse any mispellings or grammatical errors, english isn't my motherthonge.
    Last edited by IHappenToBe; Jun 21st, 2010 at 12:58 AM.

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,647

    Re: VB6 + ADODC = Terrible headache! Please please please help me...!

    I haven't worked with databound controls. But here's a thought:
    Code:
    ADODC1.DataSource="SELECT * FROM myTableName"
    Try it...

    Some useful stuff for you:

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2010
    Posts
    40

    Re: VB6 + ADODC = Terrible headache! Please please please help me...!

    Quote Originally Posted by akhileshbc View Post
    I haven't worked with databound controls. But here's a thought:
    Code:
    ADODC1.DataSource="SELECT * FROM myTableName"
    Try it...

    Some useful stuff for you:
    Hi!
    Thank you a lot, but no.

    1) I've tried it a lot and it doesn't work.
    DataSource is not a member of ADODC
    (ADODC.DataSource doesn't exist)

    However, although ADODC.Recordset.Datasource is a valid variable, I cant use it in any way. I can't even:
    PRINT ADODC.Recordset.Datasource
    a=ADODC.Recordset.Datasource
    ADODC.Recordset.Datasource = SQLCode

    the first and second one result in Error #13: Type mismatch
    and the 3rd one results in "Method or data member not found"

    2) Those link were very very purple: I've visited over and over again.


    But thanks

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,718

    Re: VB6 + ADODC = Terrible headache! Please please please help me...!

    from msdn
    Creating a Simple DataCombo Application


    The following example uses the DataCombo box control to create a data entry screen for the Titles table of the Northwind.mdb sample database. It lets the user enter new products and assign them to existing suppliers by providing a lookup table of all the suppliers' names. When users get to the Supplier field in the entry form, they can choose a supplier from a list box. When they select a supplier, that supplier's SupplierID field is copied into the SupplierID field of the Products table.

    To create a lookup table with the DataCombo control

    Create an OLEDB Data Source for the Northwind database.
    If a Data Source has not been created, follow the steps in "Creating the Northwind OLEDB Data Source."

    Create a new Standard EXE project in Visual Basic.
    If the DataGrid, DataCombo, or ADO Data Control is not present in the Toolbox, right-click the Toolbox, and use the Components dialog box to add it.

    Add a DataCombo, two ADO Data controls, and a DataGrid control to your form.


    In the Properties window, set the properties of the first data control (Adodc1) as shown in the table below.Property Setting
    Name adoDataSource
    ConnectionString Northwind.udl
    RecordSource Select * From Products;
    Caption Products


    In the Properties window, set the properties of the second data control (Adodc2) as shown in the table below.Property Setting
    Name adoRowSource
    ConnectionString Northwind.udl
    RecordSource Select CompanyName, SupplierID From Suppliers;
    Caption Suppliers
    Visible False


    In the Properties window, set the properties of the DataGrid control as shown in the table below.Property Setting
    Name grdProducts
    DataSource AdoDataSource
    Caption Products


    In the Properties window, set the properties of the DataCombo control as shown in the table below.Property Setting
    Name dcbSuppliers
    DataSource adoDataSource
    DataField SupplierID
    RowSource adoRowSource
    ListField CompanyName
    BoundColumn SupplierID


    Finally, add the following code to the form's code module:
    Private Sub Form_Load()
    ' Hide the SupplierID field in the DataGrid control, so the user is
    ' not confused on which value to change.
    grdProducts.Columns("SupplierID").Visible = False
    End Sub

    Run the project.
    You can navigate through the recordset by clicking the arrows on the visible ADO Data control. As you do so, the DataCombo control will update and display the name of the supplier for each product. To edit the SupplierID field, click the DataCombo control's arrow to display a drop-down list, then click again on a different supplier to change the value written to the SupplierID field.
    looks like you want to set the recordsource property of the adodc control
    sorry the tables did not paste too well
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2010
    Posts
    40

    Re: VB6 + ADODC = Terrible headache! Please please please help me...!

    Ahhhhhhh.......... sweet relief!!!!!

    I only needed 1 sweet word to bring me back to life! RecordSource!

    All you need to execute SQL in vb6 is:
    Code:
    ADODC.RecordSource = SQLCommand$
    ADODC.Refresh

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,718

    Re: [RESOLVED] VB6 + ADODC = Terrible headache! Please please please help me...!

    i never like to use bound controls, there are several discussions, in this and other forums, why to avoid using them
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  7. #7
    Frenzied Member
    Join Date
    Jan 2010
    Posts
    1,103

    Re: [RESOLVED] VB6 + ADODC = Terrible headache! Please please please help me...!

    If I am not wrong,ADODC is obsolete in Vista/Win7.

  8. #8
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,718

    Re: [RESOLVED] VB6 + ADODC = Terrible headache! Please please please help me...!

    If I am not wrong,ADODC is obsolete in Vista/Win7.
    so is vb6, but we are still using
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  9. #9
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,327

    Re: [RESOLVED] VB6 + ADODC = Terrible headache! Please please please help me...!

    VB6 is out of date, but the runtimes are still supported on Vista and 7... I think Jonney is referring to something about the ADODC specifically being an exception to that, but I can't remember any details myself.

  10. #10
    Frenzied Member
    Join Date
    Jan 2010
    Posts
    1,103

    Re: [RESOLVED] VB6 + ADODC = Terrible headache! Please please please help me...!

    Quote Originally Posted by si_the_geek View Post
    VB6 is out of date, but the runtimes are still supported on Vista and 7... I think Jonney is referring to something about the ADODC specifically being an exception to that, but I can't remember any details myself.
    I remembered I saw this info on expert exchange or somewhere.But I can't find now.

    http://msdn.microsoft.com/en-us/libr...vb6.adodc.aspx

    http://www.vbforums.com/showthread.php?t=617205

  11. #11
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,860

    Re: [RESOLVED] VB6 + ADODC = Terrible headache! Please please please help me...!

    There can be other confusing issues with the ADODC. If you're using a version prior to VB6 SP4 the ADODC is compiled against ADO 2.0, while the newer versions of the ADODC were compiled against ADO 2.5. In most circumstances the IDE will sniff this out and upgrade an ADO 2.0 reference to 2.5, but if you referenced ADO 2.6 or later all bets are off.

Tags for this Thread

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width