Results 1 to 10 of 10

Thread: Need Help with SQL to VB conversion

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    20

    Question Need Help with SQL to VB conversion

    Hey there,

    I am in the process of converting a few of the SQL queries into VB for the automation process..The following is the SQL query

    select a.field1,b.field2,c.fileld3
    from
    a,b,c
    where
    a.field1 *= b.field2

    I am not sure of how to convert the data that is bolded into VB code.also
    am not sure what it means..

    Can someone please help

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

    Re: Need Help with SQL to VB conversion

    I think that means 'left outer join' for some databases, so presumably this is the equivalent:
    Code:
    select a.field1,b.field2,c.fileld3
    from a Left Outer Join b on (a.field1 = b.field2), c
    Note that table c does not have a relationship specified (as it didn't in your example), so you will get a cartesian product.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    20

    Re: Need Help with SQL to VB conversion

    Hey thanks for the reply.. but this doesnt seem to work i am putting down the actual query in SQL Server and the VB version with the table name..

    SQL Server query -

    select
    cus_name,
    rou_name,
    st_sub_type,
    ct_name,
    rou_usid,
    ps_libelle,
    it_name,
    at_libelle,
    int_ip_address

    from
    router,
    planning,
    chassis_type,
    hardware,
    sita_type, interface,
    access_type,
    provisioning_status,
    customer,
    interface_type

    where
    har_rou_pk = rou_pk
    and har_ct_pk = ct_pk
    and rou_pla_pk = pla_pk
    and pla_ps_pk = ps_pk
    and int_at_pk *= at_pk
    and int_rou_pk = rou_pk
    and rou_cus_pk = cus_pk
    and cus_sita_nb in (39975)
    and rou_st_pk = st_pk
    and rou_last = 1
    and int_it_pk = it_pk
    and ps_libelle <> 'OUT'


    This is what i have with VB so far .. i have problem with tht * (bolded) how do i get the equivalent in VB..

    "select customer.cus_name,router.rou_name,sita_type.st_sub_type,chassis_type.ct_name,router.rou_usid,provisi oning_status.ps_libelle,interface_type.it_name,access_type.at_libelle,interface.int_ip_address from router,planning,chassis_type,hardware,sita_type,interface,access_type,provisioning_status,customer,i nterface_type where hardware.har_rou_pk = router.rou_pk and hardware.har_ct_pk = chassis_type.ct_pk and router.rou_pla_pk = planning.pla_pk and planning.pla_ps_pk = provisioning_status.ps_pk and interface.int_at_pk = access_type.at_pk and interface.int_rou_pk = router.rou_pk and router.rou_cus_pk = customer.cus_pk and customer.cus_sita_nb in (39975) and router.rou_st_pk = site_type.st_pk and router.rou_last = 1 and interface.int_it_pk = interface_type.it_pk and provisioning_status.ps_libelle <> 'OUT' "


    Please help me out with this.

    Thanks for ur time..

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

    Re: Need Help with SQL to VB conversion

    Which version of SQL Server are you using? (I didn't think it supported joins like that )

    Have you tried using the original query from VB?

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    20

    Re: Need Help with SQL to VB conversion

    The SQL SERVER QUERY was generated frm MSQRY32 ..

    select
    cus_name,
    rou_name,
    st_sub_type,
    ct_name,
    rou_usid,
    ps_libelle,
    it_name,
    at_libelle,
    int_ip_address

    from
    router,
    planning,
    chassis_type,
    hardware,
    sita_type, interface,
    access_type,
    provisioning_status,
    customer,
    interface_type

    where
    har_rou_pk = rou_pk
    and har_ct_pk = ct_pk
    and rou_pla_pk = pla_pk
    and pla_ps_pk = ps_pk
    and int_at_pk *= at_pk
    and int_rou_pk = rou_pk
    and rou_cus_pk = cus_pk
    and cus_sita_nb in (39975)
    and rou_st_pk = st_pk
    and rou_last = 1
    and int_it_pk = it_pk
    and ps_libelle <> 'OUT'





    and the VB query is what i wrote..

    "select customer.cus_name,router.rou_name,sita_type.st_sub_type,chassis_type.ct_name,router.rou_usid,provisi oning_status.ps_libelle,interface_type.it_name,access_type.at_libelle,interface.int_ip_address from router,planning,chassis_type,hardware,sita_type,interface,access_type,provisioning_status,customer,i nterface_type where hardware.har_rou_pk = router.rou_pk and hardware.har_ct_pk = chassis_type.ct_pk and router.rou_pla_pk = planning.pla_pk and planning.pla_ps_pk = provisioning_status.ps_pk and interface.int_at_pk = access_type.at_pk and interface.int_rou_pk = router.rou_pk and router.rou_cus_pk = customer.cus_pk and customer.cus_sita_nb in (39975) and router.rou_st_pk = site_type.st_pk and router.rou_last = 1 and interface.int_it_pk = interface_type.it_pk and provisioning_status.ps_libelle <> 'OUT' "

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    20

    Re: Need Help with SQL to VB conversion

    Helloo... any one there to help me out with this ??

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

    Re: Need Help with SQL to VB conversion

    Have you got answers to my questions?

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    20

    Re: Need Help with SQL to VB conversion

    hey MOD !!! thats what i said..i dont have any VB queries with me..i only have query frm SQLQRY32.exe .. i need the equivalent in VB..

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    20

    Re: Need Help with SQL to VB conversion

    Oops it MSQRY32.exe

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

    Re: Need Help with SQL to VB conversion

    You still have not even come close to answering my questions.

    I don't care that you are using MS Query to execute queries, what matters is the version of SQL Server that you are using. If you cant find out, execute this SQL statement and tell us the results:
    Code:
    Select @@version
    Have you tried adjusting your query to use the "LEFT OUTER JOIN" syntax that I posted?

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