Advertisement

05.04.2008 at 03:28PM PDT, ID: 23375340
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

Insert into Access database is not working? (Full code supplied)

Asked by carrzkiss in Active Server Pages (ASP)

Tags: ,

Hello All;

  I need to insert Multiple Records into a Table.
(2 Records)

Inserting a Single record works fine.
But, when I try to double it, no go.

Code is attached for the Insertion and reading from the Table(s)

Thanks All;
CarrzkissStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
<%
' *** Edit Operations: declare variables
 
MM_editAction = CStr(Request("URL"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Request.QueryString
End If
 
' boolean to abort record edit
MM_abortEdit = false
 
' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables
 
If (CStr(Request("MM_insert")) <> "") Then
 
  MM_editConnection = MM_conn_db_STRING
  MM_editTable = "MyFriends"
  MM_editColumn = "ID"
  MM_recordId = "" + Request.Form("MM_recordId") + ""
  MM_editRedirectUrl = "New_Mate_Added_Successful.asp"
  MM_fieldsStr  = "Name|value|LastName|value|MySchool|value|GradeLevel|value|DisplayPicture|value|MyAge|value|ID|value|MyID|value"
  MM_columnsStr = "Name|',none,''|LastName|',none,''|MySchool|',none,''|GradeLevel|',none,''|DisplayPicture|',none,''|MyAge|',none,''|ID|',none,''|MyID|',none,''"  
 
 
  ' 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 Request.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
%>
<%'--------------------------------------------------------------------------------------------------%>
 
 
<%
Dim imagelist__MMColParam
imagelist__MMColParam = "1"
if (Request.QueryString("art_id") <> "") then imagelist__MMColParam = Request.QueryString("art_id")
%>
<%
set imagelist = Server.CreateObject("ADODB.Recordset")
imagelist.ActiveConnection = MM_conn_db_STRING
imagelist.Source = "SELECT * FROM Users WHERE UserArtID = " + Replace(imagelist__MMColParam, "'", "''") + ""
imagelist.CursorType = 0
imagelist.CursorLocation = 2
imagelist.LockType = 3
imagelist.Open()
imagelist_numRows = 0
%>
<%
Dim MembPages__MMColParam
MembPages__MMColParam = "1"
if (Session("MM_Username") <> "") then MembPages__MMColParam = Session("MM_Username")
%>
<%
set MembPages = Server.CreateObject("ADODB.Recordset")
MembPages.ActiveConnection = MM_conn_db_STRING
MembPages.Source = "SELECT * FROM UserArticles, Users WHERE statusby = '" + Replace(MembPages__MMColParam, "'", "''") + "' ORDER BY art_title ASC"
MembPages.CursorType = 0
MembPages.CursorLocation = 2
MembPages.LockType = 3
MembPages.Open()
MembPages_numRows = 0
%>
 
      <input type="hidden" name="Name" value="<%=(imagelist.Fields.Item("Name").Value)%>">
             <input type="hidden" name="LastName" value="<%=(imagelist.Fields.Item("LastName").Value)%>">
 
      <input type="hidden" name="Name" value="<%=(MembPages.Fields.Item("Name").Value)%>">
             <input type="hidden" name="LastName" value="<%=(MembPages.Fields.Item("LastName").Value)%>">
[+][-]05.04.2008 at 03:58PM PDT, ID: 21497270

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.04.2008 at 04:52PM PDT, ID: 21497446

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.04.2008 at 04:54PM PDT, ID: 21497452

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.04.2008 at 05:03PM PDT, ID: 21497470

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.04.2008 at 05:13PM PDT, ID: 21497496

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Active Server Pages (ASP)
Tags: ASP, IE
Sign Up Now!
Solution Provided By: carrzkiss
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05.04.2008 at 05:17PM PDT, ID: 21497504

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628