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

argh! simple form to make database!! 1

Status
Not open for further replies.
May 31, 2000
13
US
Ok, this is going to seem trite to most of you i think.&nbsp;&nbsp;Basically I am trying to ask the residents of a complex that I run an ISP for whether or not they want PC access to the network.&nbsp;&nbsp;Its a small (500 host) lan that so far only allows these weak little proprietary TV computers a connection to the ethernet network.&nbsp;&nbsp;Most people would probably like to hook up their own computer to the lan.&nbsp;&nbsp;So I want to make an asp form that asks them all the following:<br>1) suite number<br>2) name<br>3) phone number<br>4) yes or no.... pc hookup.<br><br>I tried to make one using javascript, but I could only get it to email me the results of the form, and the results are god-awful ugly.<br><br>(you can check out the code at <A HREF=" TARGET="_new"> you can see, the fields are all there and just DYING for some asp/sql linkage.<br><br><br>I simply want the &quot;input&quot; button to append their info onto a database table, so that i can access the table with another asp page that loads the current list of names and numbers.&nbsp;&nbsp;Kinda like a membership list.<br><br>A third party set this site up, and there is a database already in place using &quot;Pervasive SQL server 7.0.&nbsp;&nbsp;In the last month, I have purchased :<br>&quot;Active Server Pages Unleashed&quot;<br>&quot;Beginning ASP Databases&quot;<br>&quot;Teach yourself Visual Interdev in 21 days&quot;<br>and <br>&quot;MySQL and Msql&quot; by O'rielly.<br><br>Still lost.<br>I KNOW this is a simple operation.&nbsp;&nbsp;It would only take somebody about 15 minutes to do if they knew the software.....<br>but I am at a total loss!<br><br>Basically, I would like to use ASP to snag the IP address of the poster,(hidden field) to verify their information (all the IP addresses are unique to each suite address) and have this IP appended to the form submission.<br><br>and I wouldn't even be too upset if this didn't link to a SQL database.&nbsp;&nbsp;If the thing would just email me something that was a little more readable than what I am getting I would be happy.<br><br>anybody have any ideas?<br>
 
Actually this would take 7.5 mins to do. Just kidding!<br><br>I grabbed the following from your site: <br>&lt;FORM NAME=&quot;PC_input_form&quot;&gt; <br>you're missing a method and action attribute for this FORM tag. Use POST for Method, and ACTION would be an ASP page. So your modified FORM tag would look like:<br>&lt;FORM NAME=&quot;PC_input_form&quot; Method=&quot;POST&quot; Action=&quot;SomeASPPage.asp&quot;&gt;<br>name field<br>Suite field<br>Phone number<br>Select field<br>Clear button and Send button<br>Also you need a hidden field here which will capture the IP address of the user: <br>&lt;INPUT type=&quot;hidden&quot; id=text1 name=text1 value=&quot;&lt;%Response.write(Request.ServerVariables(&quot;REMOTE_HOST&quot;))%&gt;&quot;&gt;<br>&lt;/FORM&gt;<br><br>Once the user hits the SUBMIT button, s/he will be taken to &quot;SomeASPPage.asp&quot; where you need to retrieve the values of the name, suite, phone, selectbox, and the IP. Put these in variables:<br>name = request.form(&quot;name&quot;)<br>suite = request.form(&quot;suite&quot;)<br>phone = request.form(&quot;phone&quot;)<br>ip = request.form(&quot;ip&quot;)<br><br>Now consult your books to create a DSN to the database via the control panels and then use standard ADO to open the connection to the database. Create a simple INSERT statement and execute it via the Recordset object of ADO to finish writing to the database. <br>I think thats it!
 
I know it should be simple, but I have NEVER written an asp page.<br><br>Set Conn = Server.CreateObject(&quot;ADODB.Connection&quot;)<br><br>is what i assume you&nbsp;&nbsp;mean... I can figure the rest of this out from the books i guess.&nbsp;&nbsp;My main problem is that all my books are referring to Microsoft SQL server 7.0, and the original company that set this server up installed Pervasive SQL server.&nbsp;&nbsp;None of my docs really pertain to it.<br><br>So my question for you goes back to your form:<br><br>&lt;INPUT type=&quot;hidden&quot; id=text1 name=text1 value=&quot;&lt;%Response.write(Request.ServerVariables(&quot;REMOTE_HOST&quot;))%&gt;&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/FORM&gt;<br><br>you have 'name=text1'<br><br>and then later in the second .asp page, you have <br>ip = request.form(&quot;ip&quot;)<br><br>would the line in the form that pulls the ip address have to be 'name=ip' ?<br>or 'id=ip'<br><br>I am assuming the someASPPage.asp is pulling the data from the form,&nbsp;&nbsp;but I am not sure if it is the &quot;id&quot; tag that you are using, or the &quot;name&quot; tag that i am using that the <br>request.form(&quot;_variable_&quot;) would be referring to.<br>For example I have in my form this:<br>&lt;input type=&quot;text&quot; name=&quot;nameField&quot;&gt;<br>so in the second asp page, would i use this:<br>name = request.form(&quot;nameField&quot;)<br><br>or would i have to use my form like this, with the added id tag:<br>&lt;input type=&quot;text&quot; name=&quot;nameField&quot; id=nameField&gt;<br><br>did that make sence?<br>Thanx for your help.... i am beginning to see the clouds clearing.
 
&lt;INPUT type=&quot;hidden&quot; id=text1 name=text1 value=&quot;&lt;%Response.write(Request.ServerVariables(&quot;REMOTE_HOST&quot;))%&gt;&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/FORM&gt;<br><br>you have 'name=text1'<br><br>and then later in the second .asp page, you have <br>ip = request.form(&quot;ip&quot;)<br><br>would the line in the form that pulls the ip address have to be 'name=ip' ?<br>or 'id=ip'<br><br>ANSWER: Yes, change the id and name to ip. <br><br><br>I am assuming the someASPPage.asp is pulling the data from the form,&nbsp;&nbsp;but I am not sure if it is the &quot;id&quot; tag that you are using, or the &quot;name&quot; tag that i am using that the <br>request.form(&quot;_variable_&quot;) would be referring to.<br>For example I have in my form this:<br>&lt;input type=&quot;text&quot; name=&quot;nameField&quot;&gt;<br>so in the second asp page, would i use this:<br>name = request.form(&quot;nameField&quot;)<br><br>ANSWER: Yes, that is correct. All the text, selectbox fields on the first page need to have a 'name' argument in the HTML tag. And thats what you refer to in the SomeASPPage.asp to pull the data. <br><br><br>Set Conn = Server.CreateObject(&quot;ADODB.Connection&quot;)<br><br>ASNWER: Yes, this is it. The steps would be<br>Set Conn = server.createobject(&quot;ADODB.connection&quot;)<br>conn.open &quot;DSN=DSNYoucreate&quot;,&quot;Username&quot;,&quot;Password&quot;<br>(where username and password are what you specify when creating the DSN.)<br>Set rs = server.createobject(&quot;ADODB.recordset&quot;)<br>rs.open &quot;Recordsetsource&quot;,&quot;conn&quot;<br>(where Recordsetsource could be a SQL Statement or a name of a table within the database.)<br><br>As far as creating the DSN you need to check with Pervasive SQL Server or the documentation as to which provider it supports, OLE DB or ODBC, depending on the answer you choose the right provider when creating the DSN through windows(control panel ODBC 32 source).
 
OK!!!!!<br>I think i got it!&nbsp;&nbsp;It has taken me almost 14 hours of scouring, but I think i have finally started to see the LIGHT!!!!<br><br>I created a new DSN called &quot;suites&quot; with pervasive...<br><br>in that DSN, I created a Table called PChookup.&nbsp;&nbsp;In that table, i made 6 columns.&nbsp;&nbsp;I called them : <br>firstName<br>lastName<br>IP_addr<br>phone<br>suite<br>PChook_ans <br><br>This is what I have so Far:<br><br>ok, first page, this is the page with the form on it that asks for the input of the suite's information:<br><br><br><br><br>&lt;TABLE CELLPADDING=2 CELLSPACING=5 BORDER=0 WIDTH=480 height=250 bgcolor=&quot;white&quot;&gt;<br>&lt;form action=pc_add_list.asp method=post name=PC_addfrm&gt;<br>&lt;INPUT type=hidden name=Action VALUE=Add&gt;<br>&lt;INPUT type=hidden&nbsp;&nbsp;name=IP_num value=&quot;&lt;%Response.write(Request.ServerVariables(&quot;REMOTE_ADDR&quot;))%&gt;&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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p;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td colspan=&quot;2&quot;&gt;&lt;p&gt; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;select name=hook&gt;<br> &lt;option selected value=&quot;yes&quot;&gt; Yes I would like to connect my PC<br> &lt;option value=&quot;no_pc&quot;&gt; No, Thankyou, I don't have a PC<br> &lt;option value=&quot;no_way&quot;&gt; No, Thankyou, I prefer to keep my existing provider<br> &lt;/select&gt;<br> &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;p&gt;&lt;center&gt;&lt;input type=&quot;reset&quot; value=&quot;clear&quot;&gt;&lt;/center&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;p&gt;&lt;center&gt;&lt;input type=button name=btnSubmit value=Submit&gt;&lt;/center&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/FORM&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/TABLE&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br>&nbsp;&nbsp;<br>&nbsp;&lt;script language=vbscript&gt;<br>Sub btnSubmit_OnClick()<br> 'The only required fields at this point are<br> 'last name and phone number<br> If Len(PC_addfrm.first_nameField.value) = 0 Then<br> Alert &quot;You must enter your first name&quot;<br> PC_addfrm.first_nameField.focus<br> Exit Sub<br> ElseIf Len(PC_addfrm.last_nameField.value) = 0 Then<br> Alert &quot;You must enter your last name&quot;<br> PC_addfrm.last_nameField.focus<br> Exit Sub<br> ElseIf Len(PC_addfrm.suiteField.value) &lt; 4 Then<br> Alert &quot;You must enter your suite number (ie: E1205&quot;<br> PC_addfrm.suiteField.focus<br> Exit Sub <br> ElseIf Len(PC_addfrm.phoneField.value) &lt; 8 Then<br> Alert &quot;You must enter your full Phone number (ie: 555-1234)&quot;<br> PC_addfrm.phoneField.focus<br> Exit Sub<br> End If<br> <br> 'If we make it this far then submit the form<br> Call PC_addfrm.submit()<br>End Sub<br>&lt;/script&gt;<br><br>&lt;/BODY&gt;<br>&lt;/HTML&gt;<br><br><br><br><br><br><br><br><br><br><br>then my second page comes up... the one that is called from the first one:<br>pc_add_list.asp:<br><br>I only have the begining of this page, because the stupid &quot;underscore&quot; thing is screwing me up!!!! check this out:<br><br><br><br><br>&lt;HTML&gt;<br>&lt;HEAD&gt;<br>&lt;META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Basic 6.0&quot;&gt;<br>&lt;TITLE&gt;Chapter 10 - SQL Statements That Modify Data&lt;/TITLE&gt;<br>&lt;/HEAD&gt;<br>&lt;BODY&gt;<br>The final page&lt;br&gt;&lt;br&gt;<br><br>&lt;%<br>'Declare variables needed<br>Dim strInsert<br>Dim strValues<br>Dim adCmdText<br><br>'Set required variables<br>adCmdText = 1<br> <br>'***********************************************************<br>'* If an Add was requested, add the new club to the database<br>'***********************************************************<br>If Request.Form(&quot;Action&quot;) = &quot;Add&quot; Then<br> <br> 'Start building the SQL strings with the required fields<br> strInsert = &quot;Insert into PChookup (IP_addr,lastName,firstName,phone,suite,pchook_ans)<br> strValues = &quot;Values('&quot; & CStr(Request.Form(&quot;IP_num&quot;)) & _<br> &quot;','&quot; & CStr(Request.Form(&quot;last_nameField&quot;)) & &quot;'&quot;<br> <br> 'Add meeting date if present<br> If Len(Request.Form(&quot;txtMeetingDate&quot;)) &gt; 0 Then<br> 'Add the column name to the insert string<br> strInsert = strInsert & &quot;,ClubAnnualMeeting&quot;<br> 'Add the value to the value string<br> strValues = strValues & &quot;,'&quot; & _<br> Cstr(Request.Form(&quot;txtMeetingDate&quot;)) & &quot;'&quot;<br> End If<br> <br> 'Add club dues if present<br> If Len(Request.Form(&quot;txtClubDues&quot;)) &gt; 0 Then<br> 'Add the column name to the insert string<br> strInsert = strInsert & &quot;,ClubDues&quot;<br> 'Add the value to the value string<br> strValues = strValues & &quot;,&quot; & _<br> CCur(Request.Form(&quot;txtClubDues&quot;))<br> End If<br><br> 'Add web site URL if present<br> If Len(Request.Form(&quot;txtWebSite&quot;)) &gt; 0 Then<br> 'Add the column name to the insert string<br> strInsert = strInsert & &quot;,Club 'Add the value to the value string<br> strValues = strValues & &quot;,'&quot; & _<br> Cstr(Request.Form(&quot;txtWebSite&quot;)) & &quot;'&quot;<br> End If<br><br> 'Add cranes if cheked<br> If Request.Form(&quot;chkCrane&quot;) = 1 Then<br> 'Add the column name to the insert string<br> strInsert = strInsert & &quot;,ClubHasCranes&quot;<br> 'Add True to the value string<br> strValues = strValues & &quot;,True&quot; <br> End If<br><br> 'Add club membership number if present<br> If Len(Request.Form(&quot;txtMembers&quot;)) &gt; 0 Then<br> 'Add the column name to the insert string<br> strInsert = strInsert & &quot;,ClubMembership&quot;<br> 'Add the value to the value string<br> strValues = strValues & &quot;,&quot; & _<br> CLng(Request.Form(&quot;txtMembers&quot;))<br> End If<br><br> 'Add notes if present<br> If Len(Request.Form(&quot;txtNotes&quot;)) &gt; 0 Then<br> 'Add the column name to the insert string<br> strInsert = strInsert & &quot;,ClubNote&quot;<br> 'Add the value to the value string<br> strValues = strValues & &quot;,'&quot; & _<br> Cstr(Request.Form(&quot;txtNotes&quot;)) & &quot;'&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br><br> 'Create and open the database object<br> Set objConn = Server.CreateObject(&quot;ADODB.Connection&quot;)<br> objConn.Open &quot;DSN=Sailors&quot;<br><br> 'Create the command object<br> Set objCmd = Server.CreateObject(&quot;ADODB.Command&quot;)<br><br> 'Set the command object properties<br> Set objCmd.ActiveConnection = objConn<br> objCmd.CommandText = strInsert & &quot;) &quot; & strValues & &quot;)&quot;<br> objCmd.CommandType = adCmdText<br><br> 'Execute the command<br> objCmd.Execute<br> <br> 'Display the insert string<br> Response.Write &quot;The following insert string was executed and &quot; & _<br> &quot;the values inserted into the Clubs table.&lt;P&gt;&quot;<br> Response.Write strInsert & &quot;) &quot; & strValues & &quot;)&quot;<br> <br>End If<br><br>'Close and dereference database objects<br>Set objCmd = Nothing<br>objConn.Close<br>Set objConn = Nothing<br>%&gt;<br><br>&lt;/BODY&gt;<br>&lt;/HTML&gt;<br><br><br><br><br><br>Ok, obviously I am half way into modifying a pre-existing tutorial&nbsp;&nbsp;page.... but what is screwing me up is that damned UNDERSCORE!!!<br><br>strInsert = &quot;Insert into PChookup (IP_addr,lastName,firstName,phone,suite,pchook_ans)<br> strValues = &quot;Values('&quot; & CStr(Request.Form(&quot;IP_num&quot;)) & _<br> &quot;','&quot; & CStr(Request.Form(&quot;last_nameField&quot;)) & &quot;'&quot;<br><br><br><br><br><br>The ^strValues^ section says:<br><br>strValues = &quot;Values(&quot; & CStr(Request.Form)&quot;IP_num&quot;)) & _<br><br>What is with that underscore??????&nbsp;&nbsp;I can't figure out how to finish the whole statement.&nbsp;&nbsp;I don't need all the &quot;IF &quot;variable=0&quot; statements,&nbsp;&nbsp;I just need to have a :<br><br>strInsert = &quot;Insert into PChookup (IP_addr,lastName,firstName,phone,suite,pchook_ans)<br>strValues = &quot;Values('&quot; & CStr(Request.Form(&quot;IP_num&quot;)) & _<br> &quot;','&quot; & CStr(Request.Form(&quot;last_nameField&quot;)) & &quot;'&quot;<br><br>etc and so on... but I can't re-write the code without knowing what that damn underscore is supposed to be there for.&nbsp;&nbsp;I don't requre any &quot;if's&quot; all of my variables are required, so the final page should only need two lines for the SQL.&nbsp;&nbsp;One for the strInsert, and one for the strValues.&nbsp;&nbsp;&nbsp;But that underscore is really confusing me!<br><br>all of my columns in my table are of the &quot;char&quot; type, <br><br>god ... i felt so GREAT about four hours ago... thought I had IT!<br>now I am lost again.<br><br>thanx in advance.<br>
 
You're almost there. The underscore is simply a line continuation character, for when a line is longer than the width of your screen. You can simply erase it and type your code all on one line.<br><br>A bit of advice - put your request.form stuff into variables, then use them in your code. It will make your code cleaner and easier to read, and it's good programming style. So..<br><br>ip_addr = request.form(&quot;ip_num&quot;)<br>lastName = Request.Form(&quot;last_nameField&quot;)<br><br>then..<br><br>strInsert = &quot;Insert into PChookup (IP_addr,lastName,firstName,phone,suite,pchook_ans)<br>strValues = &quot;Values('&quot; & ipaddr & &quot;','&quot; & lastName & &quot;',&quot;<br><br>etc...<br><br>Bill Burns<br><br><br>
 
GOT IT!<br><br>'Start building the SQL strings with the required fields<br> strInsert = &quot;Insert into PChookup (IP_addr,lastName,firstName,phone,suite,pchook_ans&quot;<br> strValues = &quot;Values('&quot; & CStr(Request.Form(&quot;IP_num&quot;)) & _<br> &quot;','&quot; & CStr(Request.Form(&quot;last_nameField&quot;)) & &quot;'&quot;<br> <br> <br> strValues = strValues & &quot;,'&quot; & _<br> Cstr(Request.Form(&quot;first_nameField&quot;)) & &quot;'&quot;<br> strValues = strValues & &quot;,'&quot; & _<br> Cstr(Request.Form(&quot;phoneField&quot;)) & &quot;'&quot; <br> strValues = strValues & &quot;,'&quot; & _<br> Cstr(Request.Form(&quot;suiteField&quot;)) & &quot;'&quot; <br> strValues = strValues & &quot;,'&quot; & _<br> Cstr(Request.Form(&quot;hook&quot;)) & &quot;'&quot; <br> <br> <br><br> <br><br> 'Create and open the database object<br> Set objConn = Server.CreateObject(&quot;ADODB.Connection&quot;)<br> objConn.Open &quot;suites&quot;, &quot;usrname&quot;, &quot;password&quot;<br><br> 'Create the command object<br> Set objCmd = Server.CreateObject(&quot;ADODB.Command&quot;)<br><br> 'Set the command object properties<br> Set objCmd.ActiveConnection = objConn<br> objCmd.CommandText = strInsert & &quot;) &quot; & strValues & &quot;)&quot;<br> objCmd.CommandType = adCmdText<br><br> 'Execute the command<br> objCmd.Execute<br> <br> 'Display the insert string<br> Response.Write &quot;Thank you for your input.&nbsp;&nbsp;You will be contacted within the next few days &quot; <br> <br> <br> <br>End If<br><br>'Close and dereference database objects<br>Set objCmd = Nothing<br>objConn.Close<br>Set objConn = Nothing<br>%&gt;<br>__________________________________________________<br><br><br>Then the page I use to pull the values up is this:<br><br>&lt;%<br> 'Dim oRSs<br> Dim oConn<br> Set oConn = Server.CreateObject (&quot;ADODB.connection&quot;)<br> 'Set oRSs = Server.CreateObject(&quot;ADODB.recordset&quot;)<br> 'oRSs.Open &quot;PChookup&quot;, &quot;DSN==suites&quot;, &quot;sa&quot;, &quot;&quot;<br> oConn.Open &quot;suites&quot;, &quot;usrname&quot;, &quot;password&quot;<br> 'strSQL = &quot;SELECT IP_addr, pcHook_ans, phone, lastName, firstName, suite FROM PCHookup ORDER BY IP_addr DESC;&quot;<br> strSQL = &quot;SELECT IP_addr, pcHook_ans, phone, lastName, firstName, suite FROM PCHookup&quot;<br> <br> Set rsSuite = oConn.Execute(strSQL)<br> <br> If rsSuite.EOF Then<br>&nbsp;&nbsp;<br> Response.Write &quot;Sorry, nobody has filled out the form&quot;<br> Else<br> %&gt; <br>&nbsp;&nbsp;&lt;TR&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;TD&gt;&lt;STRONG&gt;Suite #&lt;/STRONG&gt; &lt;/TD&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;TD&gt;&lt;STRONG&gt;(IP ADDRESS)&lt;/STRONG&gt; &lt;/TD&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;TD&gt;&lt;STRONG&gt;First Name&lt;/STRONG&gt; &lt;/TD&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;TD&gt;&lt;STRONG&gt;Last Name&lt;/STRONG&gt; &lt;/TD&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;TD&gt;&lt;STRONG&gt;Phone Number&lt;/STRONG&gt; &lt;/TD&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;TD&gt;&lt;STRONG&gt;Answer&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;%<br>&nbsp;&nbsp;&nbsp;&nbsp;While NOT rsSuite.EOF<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;'Session(&quot;IP_addr&quot;) = rsSuite.Fields(0)<br> 'Session(&quot;answer&quot;) = rsSuite.Fields(1)<br> 'Session(&quot;phone&quot;) = rsSuite.Fields(2)<br> 'Session(&quot;lName&quot;) = rsSuite.Fields(3)<br> 'Session(&quot;fName&quot;) = rsSuite.Fields(4)<br> 'Session(&quot;suite&quot;) = rsSuite.Fields(5)<br> <br>&nbsp;&nbsp;Response.Write &quot;&lt;TR&gt;&lt;TD&gt;&quot; & rsSuite(5)&&nbsp;&nbsp;&quot;&lt;/TD&gt;&quot;<br>&nbsp;&nbsp;Response.Write&nbsp;&nbsp;&quot;&lt;TD&gt;&quot; & rsSuite(0)&&nbsp;&nbsp;&quot;&lt;/TD&gt;&quot;<br>&nbsp;&nbsp;Response.Write&nbsp;&nbsp;&quot;&lt;TD&gt;&quot; & rsSuite(4)&&nbsp;&nbsp;&quot;&lt;/TD&gt;&quot;<br>&nbsp;&nbsp;Response.Write&nbsp;&nbsp;&quot;&lt;TD&gt;&quot; & rsSuite(3)&&nbsp;&nbsp;&quot;&lt;/TD&gt;&quot;<br>&nbsp;&nbsp;Response.Write&nbsp;&nbsp;&quot;&lt;TD&gt;&quot; & rsSuite(2)&&nbsp;&nbsp;&quot;&lt;/TD&gt;&quot;<br>&nbsp;&nbsp;Response.Write&nbsp;&nbsp;&quot;&lt;TD&gt;&quot; & rsSuite(1)&&nbsp;&nbsp;&quot;&lt;/TD&gt;&lt;/TR&gt;&quot;<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;rsSuite.MoveNext<br>&nbsp;&nbsp;WEND<br>&nbsp;&nbsp;Response.Write &quot;&lt;/table&gt;&quot;<br>&nbsp;&nbsp;end if<br>&nbsp;&nbsp;%&gt;&lt;/TABLE&gt;<br><br><br>&gt;&gt;&gt;&nbsp;&nbsp;Notice how i had to comment out the object.recordset?&nbsp;&nbsp;For some reason, the server wouldn't recognise it.&nbsp;&nbsp;I kept getting &quot;type mismatch error: open&quot;<br>when trying to run the page.&nbsp;&nbsp;The book I have covers the first 4 chapters only using the recordset parameter.. not the connection parameter.<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top