Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Re: help me


Message #1 by "geoff rogers" <geoffrogers444@h...> on Wed, 27 Nov 2002 17:15:11
Try the following line in your code and have a look to see if the number 
of items you are submitting matches the number the datbase is expecting.
Comment out the execute statement and Response.Write the querystring you 
are submitting. You should also comment out the redirect code so it stays 
on the same page when you try this.  e.g. (the stars just make the 
comments easier to see).

'*** execute the insert
  dim MM_editCmd1
  set MM_editCmd1 = Server.CreateObject("ADODB.Command")
  MM_editCmd1.ActiveConnection = MM_EEF_STRING
  MM_editCmd1.CommandText = MM_editQuery1
  Response.Write(MM_editQuery1)
  '***MM_editCmd1.Execute()
  MM_editCmd1.ActiveConnection.Close()
  set MM_editCmd1 = Nothing 

In your code this would be

 >    '***execute the insert
 >    Set MM_editCmd = Server.CreateObject("ADODB.Command")
 >    MM_editCmd.ActiveConnection = MM_editConnection
 >    MM_editCmd.CommandText = MM_editQuery
      Response.Write(MM_editQuery)
 >    '***MM_editCmd.Execute
 >    MM_editCmd.ActiveConnection.Close

>     '***If (MM_editRedirectUrl <> "") Then
 >      '***Response.Redirect(MM_editRedirectUrl)
 >    '***End If
 >  End If

> End If
%> >

> Hi,
P> lease help me if you can as everything I have tried has failed and this 
i> s the idea I got, ?to ask!?
I>  can view the database no problem but can't write/update it.
I>  always get the following error:

> ?Error Type:
M> icrosoft JET Database Engine (0x80040E14)
S> yntax error in INSERT INTO statement.
/> insert.asp, line 90?

> No userid/paswords have been set.
I>  connect to the database using an OLEDB connection.
I>  am using a database created in access2002

> i am using Dreamweaver 4 which (I don't know if you are 
f> amiliar with) makes the connection string as a file and calls it up in 
t> he page.
I> t creates its own asp codes.. couldn?t make out anything else.
M> y os is winxp using iis

> Here is the code .
L> ooking forward for a solution!
T> hanks you,

> Ameer

> <%@LANGUAGE="VBSCRIPT"%>
<> !--#include file="Connections/test.asp" -->
<> %
'>  *** Edit Operations: declare variables

> MM_editAction = CStr(Request("URL"))
I> f (Request.QueryString <> "") Then
 >  MM_editAction = MM_editAction & "?" & Request.QueryString
E> nd If

> ' boolean to abort record edit
M> M_abortEdit = false

> ' query string to execute
M> M_editQuery = ""
%> >
<> %
'>  *** Insert Record: set variables

> If (CStr(Request("MM_insert")) <> "") Then

>   MM_editConnection = MM_test_STRING
 >  MM_editTable = "tb_bio"
 >  MM_editRedirectUrl = "default.asp"
 >  MM_fieldsStr  = "address|value|name|value|no|value"
 >  MM_columnsStr = "address|',none,''|name|',none,''|no|none,none,NULL"

>   ' create the MM_fields and MM_columns arrays
 >  MM_fields = Split(MM_fieldsStr, "|")
 >  MM_columns = Split(MM_columnsStr, "|")
 >  
 >  ' set the form values
 >  For i = LBound(MM_fields) To UBound(MM_fields) Step 2
 >    MM_fields(i+1) = CStr(Request.Form(MM_fields(i)))
 >  Next

>   ' append the query string to the redirect URL
 >  If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
 >    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And 
R> equest.QueryString <> "") Then
 >      MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
 >    Else
 >      MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
 >    End If
 >  End If

> End If
%> >
<> %
'>  *** Insert Record: construct a sql insert statement and execute it

> If (CStr(Request("MM_insert")) <> "") Then

>   ' create the sql insert statement
 >  MM_tableValues = ""
 >  MM_dbValues = ""
 >  For i = LBound(MM_fields) To UBound(MM_fields) Step 2
 >    FormVal = MM_fields(i+1)
 >    MM_typeArray = Split(MM_columns(i+1),",")
 >    Delim = MM_typeArray(0)
 >    If (Delim = "none") Then Delim = ""
 >    AltVal = MM_typeArray(1)
 >    If (AltVal = "none") Then AltVal = ""
 >    EmptyVal = MM_typeArray(2)
 >    If (EmptyVal = "none") Then EmptyVal = ""
 >    If (FormVal = "") Then
 >      FormVal = EmptyVal
 >    Else
 >      If (AltVal <> "") Then
 >        FormVal = AltVal
 >      ElseIf (Delim = "'") Then  ' escape quotes
 >        FormVal = "'" & Replace(FormVal,"'","''") & "'"
 >      Else
 >        FormVal = Delim + FormVal + Delim
 >      End If
 >    End If
 >    If (i <> LBound(MM_fields)) Then
 >      MM_tableValues = MM_tableValues & ","
 >      MM_dbValues = MM_dbValues & ","
 >    End if
 >    MM_tableValues = MM_tableValues & MM_columns(i)
 >    MM_dbValues = MM_dbValues & FormVal
 >  Next
 >  MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues 
&>  ") values (" & MM_dbValues & ")"

>   If (Not MM_abortEdit) Then
 >    ' execute the insert
 >    Set MM_editCmd = Server.CreateObject("ADODB.Command")
 >    MM_editCmd.ActiveConnection = MM_editConnection
 >    MM_editCmd.CommandText = MM_editQuery
 >    MM_editCmd.Execute
 >    MM_editCmd.ActiveConnection.Close

>     If (MM_editRedirectUrl <> "") Then
 >      Response.Redirect(MM_editRedirectUrl)
 >    End If
 >  End If

> End If
%> >

  Return to Index