[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
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.
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.
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')
Re: convert to sql syntax.