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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Into 1

Status
Not open for further replies.

Ablecken

Programmer
Jun 5, 2001
130
US
Does anybody see anything wrong with this statement. All values are text. It says that there is a syntax error.

INSERT INTO userlogin (user,securitylevel,password) VALUES ('Terry','3','terry')

Thanx

Justin
 
your syntax looks fine. try pasting the sql directly into the db (query analyzer or something like that), and see if that works. If it does, then it's something with your code. leo

------------
Leo Mendoza
lmendoza@garbersoft.net
 
try this
INSERT INTO userlogin (user,securitylevel,password) VALUES (SELECT 'Terry','3','terry')
 
all right,

I put it in the database and it updated fine.

I have another connection that does the same thing to a different table in the same database and it works fine.

Code:
<%
'on error resume next
dim y, newdownload, newfile, conn, goforit, sConnString, mySQL, rs, action, table, which, newuser, newlevel, newpass, newtable, newid, newOne, newTwo

goforit=request(&quot;go&quot;)
action=request(&quot;action&quot;)
table=request(&quot;table&quot;)
which=request(&quot;which&quot;)
newuser=request(&quot;user&quot;)
newlevel=request(&quot;level&quot;)
newpass1=request(&quot;pass&quot;)
newtable=request(&quot;table&quot;)
newid=request(&quot;id&quot;)
newOne=request(&quot;one&quot;)
newTwo=request(&quot;two&quot;)
newdownload=request(&quot;download&quot;)
newfile=request(&quot;file&quot;)
newlocation=request(&quot;location&quot;)
newchange=request(&quot;change&quot;)
newpass=request(&quot;newpass&quot;)
oldpass=request(&quot;oldpass&quot;)
y=request(&quot;y&quot;)

Const adOpenStatic=3
Const adLockOptimistic=3
Const adCmdText=1

if action=&quot;changepass&quot; and newchange then
mySQL=&quot;SELECT * FROM userlogin where user='&quot; & session(&quot;name&quot;) & &quot;'&quot;
'mySQL=&quot;SELECT * FROM userlogin WHERE (((userlogin.user)='&quot; & session(&quot;name&quot;) & &quot;'))&quot;

'mySQL= &quot;UPDATE userlogin &quot;
'mySQL= mySQL & &quot;SET password='&quot; & newpass & &quot;'&quot;
'mySQL= mySQL & &quot; WHERE user='&quot; & session(&quot;name&quot;) & &quot;'&quot;
end if

if action=&quot;delete&quot; then 
mySQL=&quot;DELETE FROM &quot; & table & &quot; WHERE [<AutoNumber>]=&quot; & which
end if

if action=&quot;edit&quot; then
mySQL=&quot;SELECT * FROM &quot; & table & &quot; WHERE [<AutoNumber>]=&quot; & which
end if

if action=&quot;adding&quot; and table=&quot;download&quot; then
mySQL = &quot;INSERT INTO download (file,downloaded,location) &quot;
mySQL = mySQL & &quot;VALUES ('&quot; & newfile & &quot;','&quot; & newdownload & &quot;','&quot; & newlocation & &quot;')&quot;
end if

if action=&quot;adding&quot; and table=&quot;userlogin&quot; then
mySQL = &quot;INSERT INTO userlogin (user,securitylevel,password) &quot;
mySQL = mySQL & &quot;VALUES ('&quot; & newuser & &quot;','&quot; & newlevel & &quot;','&quot; & newpass1 & &quot;')&quot;
end if

if action=&quot;adding&quot; and table=&quot;test&quot; then
newid = replace(newid,&quot;'&quot;,&quot;''&quot;)
newOne = replace(newOne,&quot;'&quot;,&quot;''&quot;)
newTwo = replace(newTwo,&quot;'&quot;,&quot;''&quot;)
mySQL = &quot;INSERT INTO test (ID,One,Two) &quot;
mySQL = mySQL & &quot;VALUES ('&quot; & newid & &quot;','&quot; & newOne & &quot;','&quot; & newTwo & &quot;')&quot;
end if

response.write mySQL 
response.write &quot;<br>&quot;
response.write request(&quot;pass&quot;)

where=request(&quot;location&quot;)

if goforit=&quot;go&quot; then
	'--comment-- Below is the ADO connection used in brinkster.com --commment---
	sConnString = &quot;Provider=Microsoft.Jet.OLEDB.4.0; Data Source=&quot; & _ 
	&quot;\\premfs3\sites\premium8\mlabsusa\database\mlabs.mdb;&quot; & _ 
	&quot;Persist Security Info=False;&quot;
	
	Select Case action
		case &quot;changepass&quot;
			set conn=server.createobject(&quot;adodb.connection&quot;)
			set rst=server.createobject(&quot;adodb.recordset&quot;)


			conn.open sConnString
			'conn.execute(mySQL)
			rst.Open mySQL, conn, adOpenStatic, adLockOptimistic, adCmdText
			if oldpass=rst(&quot;Password&quot;) then
				rst(&quot;Password&quot;)=newpass
				rst.update
				msg=&quot;<font color='red'><b>Password successfully changed</b></font>&quot;			
			else
				msg=&quot;<font color='red'><b>Could not change password.  Old password does not match.</b></font>&quot;
			end if
		case &quot;edit&quot;
			set conn=server.createobject(&quot;adodb.connection&quot;)
			set rst=server.createobject(&quot;adodb.recordset&quot;)
			
			conn.open sConnString
			rst.Open mySQL, conn, adOpenStatic, adLockOptimistic, adCmdText
			if y=&quot;true&quot; then
				Select Case table
					case &quot;download&quot;
						rst(&quot;File&quot;)=newfile
						rst(&quot;downloaded&quot;)=newdownload
						rst(&quot;Location&quot;)=newlocation
						rst.update
					case &quot;test&quot;
						rst(&quot;ID&quot;)=newid
						rst(&quot;One&quot;)=newone
						rst(&quot;Two&quot;)=newtwo
						rst.update
					case &quot;userlogin&quot;
						rst(&quot;user&quot;)=newuser
						rst(&quot;securitylevel&quot;)=newlevel
						rst(&quot;password&quot;)=newpass
						rst.update
					
				end select
				editmsg=&quot;<font color='red'><b>Secessfully Updated</b></font>&quot;
				'rst.close
				'rst.Open mySQL, conn, adOpenStatic, adLockOptimistic, adCmdText
			end if
		case else
			set conn=server.createobject(&quot;adodb.connection&quot;)
			conn.open(sConnString)
			conn.execute(mySQL)
			Conn.Close
			set conn=nothing
	end select
end if
the error is happening on the conn.execute(mySQL) line.

As you can see the test table is the same thing except for the replace part. It works.

:-(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top