|
-
May 6th, 2006, 10:41 PM
#1
Thread Starter
Fanatic Member
[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:
With Adodc1.Recordset
.AddNew
.Fields("FirstName") = UCase(txtFName.Text)
.Fields("LastName") = UCase(txtLName.Text)
.Fields("Claim") = txtClaim.Text
.Fields("MCO") = UCase(txtMCO.Text)
.Fields("AuthStart") = txtAuthStart.Text
.Fields("AuthEnd") = txtAuthEnd.Text
.Fields("Provider") = UCase(txtProvider.Text)
.Fields("Sessions") = txtSessions.Text
.Update
End With
-
May 6th, 2006, 11:00 PM
#2
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.
-
May 6th, 2006, 11:03 PM
#3
Thread Starter
Fanatic Member
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.
-
May 6th, 2006, 11:41 PM
#4
Re: convert to sql syntax.
Use the Insert statement for new records, no Where clause required.
VB Code:
strSQL = "Insert Into <tablename> Values('" & _
Ucase(txtFName.Text) & "', '" & _
UCase(txtLName.Text) & "', '" & _
txtClaim.Text & "', '" & _
UCase(txtMCO) & "', '" & _
txtAuthStart.Text & "', '" & _
txtAuthEnd.Text & "', '" & _
UCase(txtProvider.Text) & "', '" & _
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')
-
May 6th, 2006, 11:44 PM
#5
Thread Starter
Fanatic Member
Re: convert to sql syntax.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|