Results 1 to 5 of 5

Thread: [RESOLVED] convert to sql syntax.

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2006
    Posts
    607

    Resolved [RESOLVED] convert to sql syntax.

    Is it possible to convert the following in to SQL syntax?

    what i mean is that it should use a 'query'.

    VB Code:
    1. With Adodc1.Recordset
    2.             .AddNew
    3.             .Fields("FirstName") = UCase(txtFName.Text)
    4.             .Fields("LastName") = UCase(txtLName.Text)
    5.             .Fields("Claim") = txtClaim.Text
    6.             .Fields("MCO") = UCase(txtMCO.Text)
    7.             .Fields("AuthStart") = txtAuthStart.Text
    8.             .Fields("AuthEnd") = txtAuthEnd.Text
    9.             .Fields("Provider") = UCase(txtProvider.Text)
    10.             .Fields("Sessions") = txtSessions.Text
    11.             .Update
    12.         End With

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: convert to sql syntax.

    Assuming that all your fields are character fields:

    Code:
    strSQL = "Update <tablename> Set FirstName = '" & Ucase(txtFName.Text) & "', " & _
    "LastName = '" & UCase(txtLName.Text) & "', " & _
    "Claim = '" & txtClaim.Text & "', " & _
    "MCO = '" & UCase(txtMCO) & "', " & _
    "AuthStart = '" & txtAuthStart.Text & "', " & _
    "AuthEnd" =  '" & txtAuthEnd.Text & "', " & _
    "Provider = '" & UCase(txtProvider.Text) & "', " & _
    "Sessions = '" & txtSessions.Text & '"
    You'd want a Where clause in there too, so that you'd update the correct rrcord. You could get that by looking at the Select statement that populated your recordset.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2006
    Posts
    607

    Re: convert to sql syntax.

    its a new record though, and its gotta go at the end of the table so what do i put for the WHERE clause.

  4. #4
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: convert to sql syntax.

    Use the Insert statement for new records, no Where clause required.

    VB Code:
    1. strSQL = "Insert Into <tablename> Values('" & _
    2. Ucase(txtFName.Text) & "', '" & _
    3. UCase(txtLName.Text) & "', '" & _
    4. txtClaim.Text & "', '" & _
    5. UCase(txtMCO) & "', '" & _
    6. txtAuthStart.Text & "', '" & _
    7. txtAuthEnd.Text & "', '" & _
    8. UCase(txtProvider.Text) & "', '" & _
    9. txtSessions.Text & "')"

    The above syntax requires that every field in the database table is listed in the Values clause and in the correct order. Otherwise you need to list the fields to which you are inserting data.

    Insert Into TableName (LastName, Claim, MCO) Values ('X','Y','Z')

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2006
    Posts
    607

    Re: convert to sql syntax.

    thankyou

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