Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert into adding a leading space 1

Status
Not open for further replies.

evr72

MIS
Dec 8, 2009
265
0
0
US
Hello,

Thanks to this forum and Mr. Gmmastros and Mr. BigRed1212
I was able to build a complex form, it works well. The problem I am having is that my insert is adding a leading space on records two and up. The first record goes in with out an space but the subsequent records have a space. I have looked at different approches but have not come up with a solution. wondering if anybody could give me some other ideas.

the insert code
Code:
<%

'declare your variables
Dim itm, userid, responses, keycontrol, comm, reviewnote, i
Dim sConnString, connection, sSQL
'Receiving values from Form, assign the values entered to variables
itm = Split(Request.Form("itm"),",")
responses = Split(Request.Form("responses"),",")
userid = Split(Request.Form("userid"),",")
keycontrol = Split(Request.Form("keycontrol"),",")
comm = Split(Request.Form("comm"),",")
reviewnote = Split(Request.Form("reviewnote"),",")


'define the connection string, specify database
'driver and the location of database
sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("qa.mdb")
'create an ADO connection object
Set connection = Server.CreateObject("ADODB.Connection")

'Open the connection to the database
connection.Open(sConnString)


For i = lBound(userid) to ubound(userid)


  'declare SQL statement that will query the database
  sSQL = "INSERT into answers1 (userid,itm, responses, keycontrol, comm, reviewnote) values ('" & _
userid(i) & "','" & itm(i) & "','" & responses(i) & "','" & keycontrol(i) & "','" & comm(i) & "','" & reviewnote(i) & "')"
  connection.execute(sSQL)
Next


'execute the SQL
' connection.execute(sSQL) don't need this line anymore
'Done. Close the connection object
connection.Close
Set connection = Nothing


%>

Thanks!!!
 
use the trim function, like this:

Code:
sSQL = "INSERT into answers1 (userid,itm, responses, keycontrol, comm, reviewnote) values ('" & _
[!]Trim([/!]userid(i)[!])[/!] & "','" & [!]Trim([/!]itm(i)[!])[/!] & "','" & responses(i) & "','" & keycontrol(i) & "','" & comm(i) & "','" & reviewnote(i) & "')"

Repeat the code highlighted in red with your other values.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Again, I thank you Mr. gmmastros, I was doing a the trim after the insert into answers1, I did try the trim in the value but did not put parentesis


Thaks!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top