Results 1 to 9 of 9

Thread: Variables in databases

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2004
    Posts
    220

    Variables in databases

    Hi, i am using variables in database but both times they dont work.

    First example is, problem is there is no error message apart from sayin that its not there, so i knwo the syntax is A valid one but whether its right ?????

    VB Code:
    1. If cmdStartStop.Caption = "Stop Campaign" Then
    2. NotRunning.Source = "Select * From T_Campaigns WHERE Campaign_Name = ' " & lstNotRunning.Text & " ' ;"
    3. NotRunning.Open , db, adOpenKeyset, adLockOptimistic
    4. With NotRunning
    5. .Fields("Live").Value = "Not Running"
    6. .Update
    7. NotRunning.Close
    8. Call ListLoad
    9. End With
    10. End If

    and the second is on a different form but same thing, dont pick it up

    VB Code:
    1. If db Is Nothing Then OpenConnectionCampaign
    2.   Set CallBack = New ADODB.Recordset
    3.   CallBack.Open "SHAPE {SELECT & 'CallBackList' & FROM Data WHERE CallBack = 'True' } AS ParentCMD2 APPEND ({SELECT '& CallBackList &' FROM Data WHERE CallBack = 'True'} AS ChildCMD2 RELATE Telephone_Number TO Telephone_Number) AS ChildCMD2", db, adOpenStatic, adLockOptimistic
    4.   bCancelResult = False
    5.   Set grdDataGrid.DataSource = CallBack.DataSource

    any idea's

    tnx

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Apr 2004
    Posts
    220
    ??

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 2004
    Posts
    220
    lol i take it no1 know, coz it just aint pickin them up, i have tried different syntax but still nothing


  4. #4
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670
    VB Code:
    1. NotRunning.Source = "Select * From T_Campaigns WHERE Campaign_Name = ' " & lstNotRunning.Text & " ' ;"

    well this one is putting a SPACE either side of the variable so you won't find the Campaign_Name matching your variable - change it to:

    VB Code:
    1. NotRunning.Source = "Select * From T_Campaigns WHERE Campaign_Name = '" & lstNotRunning.Text & "' ;"


    And

    VB Code:
    1. CallBack.Open "SHAPE {SELECT & 'CallBackList' & FROM Data WHERE CallBack = 'True' } AS ParentCMD2 APPEND ({SELECT '& CallBackList &' FROM Data WHERE CallBack = 'True'} AS ChildCMD2 RELATE Telephone_Number TO Telephone_Number) AS ChildCMD2", db, adOpenStatic, adLockOptimistic

    With this one you are not 'breaking out' of the string to add your variable names in - try this

    VB Code:
    1. CallBack.Open "SHAPE {SELECT '" & CallBackList  & "' FROM Data WHERE CallBack = 'True' } AS ParentCMD2 APPEND ({SELECT '" & CallBackList &"' FROM Data WHERE CallBack = 'True'} AS ChildCMD2 RELATE Telephone_Number TO Telephone_Number) AS ChildCMD2", db, adOpenStatic, adLockOptimistic
    'Buzby'
    Visual Basic Developer
    "I'm moving to Theory. Everything works there."

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Apr 2004
    Posts
    220
    Unfortunatly still nothing on both



    for the CallBack

    Dim CallBackList As String
    CallBackList = "Telephone_Number,DateOfCallBack"

    i have checked spelling as well but still nothing.

    and for the first one is it listbox.text to look at the selected item or is it something different

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Apr 2004
    Posts
    220
    I still aint figured it out,any1 got any idea's or want any more info

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Apr 2004
    Posts
    220
    how do i use the listview.text, im sure whether that is right ?

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Apr 2004
    Posts
    220
    Ok, i still aint figure it out but if i show it 1 by 1, you might be able to help

    VB Code:
    1. Dim CallBackList As String
    2. CallBackList = "Telephone_Number,DateOfCallBack"
    3.  
    4. Set db = Nothing
    5.   If db Is Nothing Then OpenConnectionCampaign
    6.   Set CallBack = New ADODB.Recordset
    7.   CallBack.Open "SHAPE {SELECT '" & CallBackList & "' FROM Data WHERE CallBack = 'True' } AS ParentCMD2 APPEND ({SELECT '" & CallBackList & "' FROM Data WHERE CallBack = 'True'} AS ChildCMD2 RELATE Telephone_Number TO Telephone_Number) AS ChildCMD2", db, adOpenStatic, adLockOptimistic
    8.   bCancelResult = False
    9.   Set grdDataGrid.DataSource = CallBack.DataSource

    That is the first one and the other one i have resovled
    Last edited by k0r54; Jun 18th, 2004 at 03:51 AM.

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Apr 2004
    Posts
    220
    The error i am gettin is

    Column (Telephone_Number) does not exist in the appropraite row set.

    Im not sure what this means but, all fields are field in.

    im goin with this

    any help will be great cheers

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