Database Connection

Results 1 to 5 of 5

Thread: Database Connection

  1. #1
    sshine Guest

    Default Database Connection

    I'm trying to link my Submit and Search buttons to my Access database but am unsure of the code needed. I'm using an eCommerce software package similar to WYSIWYG but this part involves asp. Thanks!

  2. #2 Guest

    Default Too vague to answer

    Please give some idea what you want to do.<BR><BR>However, basically you could simply have a have a search field and a submit:<BR><BR>Search: &#060;input type=text name=txtSearch&#062;<BR>&#060;input type=submit value="Search"&#062;<BR><BR>Then in the asp page you have:<BR><BR>&#060;%<BR>Qry = "Select * from YourTable where txtField like &#039;%" & Request.Form("txtSearch") & "%&#039;;"<BR>Set Rs=objConn.Execute(Qry)<BR>Do while not Rs.EOF<BR>&nbsp;&nbsp;&nbsp;&#039; some code to display the desired fields.<BR>&nbsp;&nbsp;&nbsp;Rs.Movenext<BR>Loop<B R>Rs.Close<BR>Set Rs=Nothing<BR>%&#062;

  3. #3
    sshine Guest

    Default RE: Too vague to answer

    Thanks for the response, but I&#039;m still confused. Here&#039;s the detailed description. I&#039;m using WebShop Designer 2000. This is an application for developing webpages. All you have to do is drag and drop, what you see is what you get. I have created an Access database (Alumni.mdb) and I have imported this database into my application. One of my pages within the application is a form that has a submit, search and reset button. Now here&#039;s where my problem begins, when I click on the Submit button, instead of "hitting" the database, it is going to an asp file (CGI-BIN.asp) so I&#039;m thinking I need to add some configuration into this file, but I have no idea what or where. I&#039;m also sending the file for everyone&#039;s viewing pleasure. Any help with this would be greatly appreciated. Here are the contents of the CGI-BIN.asp file: (All of this came with the package, I haven&#039;t added anything!)<BR><BR><BR>&#060;%<BR>&#039;----------General section------------<BR>CURRENT_VERSION = ("2000")<BR>CURRENT_STYLE = ("../../.css")<BR>FormAction = ("CGI2.asp")<BR>ScriptRelativeFolder = ("WebSiteCGI-BIN")<BR>pos=InstrRev(LCase(Request.ServerVariable s("PATH_TRANSLATED")),LCase(ScriptRelativeFolder ) & "\" & LCase(FormAction))<BR>BS_Root = Left(Request.ServerVariables("PATH_TRANSLATED"), pos-1 )<BR>DB_Path =BS_Root & "\"<BR>ScriptFolderAddress =BS_Root & "\" & ScriptRelativeFolder & "\"<BR>URL =Request.ServerVariables("URL")<BR>SERVER_NAME=Req uest.ServerVariables("SERVER_NAME")<BR>SERVER_NAME ="http://"&SERVER_NAME&URL<BR>ScriptRelativeFolder = ("WebSite/CGI-BIN")<BR>pos=InstrRev(LCase(SERVER_NAME),LCase(Scr iptRelativeFolder) & "/" & LCase(FormAction))<BR>BS_Root_URL = Left(SERVER_NAME, pos-1)<BR>CurrentFolder = BS_Root_URL &ScriptRelativeFolder& "/"<BR>BS_Root_URL = BS_Root_URL & "/"<BR>bHeaderFired = FALSE<BR><BR>&#039;==========Constants============ =<BR>&#039;---- CursorTypeEnum Values ----<BR>Const adOpenForwardOnly = 0<BR>Const adOpenKeyset = 1<BR>Const adOpenDynamic = 2<BR>Const adOpenStatic = 3<BR><BR>&#039;---- LockTypeEnum Values ----<BR>Const adLockReadOnly = 1<BR>Const adLockPessimistic = 2<BR>Const adLockOptimistic = 3<BR>Const adLockBatchOptimistic = 4<BR>&#039;=========End of Section===========<BR><BR>&#039;Subroutins<BR>Sub PushVars()<BR>end sub<BR>Sub PopVars()<BR>end sub<BR>Sub RestoreVars()<BR>end sub<BR><BR>&#039;Functions that in the future should be placed in stanalone .INC File<BR>&#039;Function to format date string<BR>Function format_date(date,dataformat)<BR> months =Array("January","February","March","April","May", "June","July","August","September","October","Nove mber","December")<BR> mon = Array("Jan","Feb","Mar","Apr","May","Jun","Jul","A ug","Sep","Oct","Nov","Dec")<BR> &#039;dd-MMM-yyyy = 0<BR> &#039;MM/dd/yyyy = 1<BR> &#039;dd MMMM,yyyy = 2<BR> &#039;MMMM dd,yyyy = 3<BR> daypart = Day(date)<BR> monthpart = Month(date)<BR> yearpart = Year(date)<BR> monthpart = monthpart -1<BR> if(dataformat = 0) then<BR> format_date = daypart & " " & mon(monthpart) & "," & yearpart<BR> end if<BR> if(dataformat = 1) then<BR> format_date = monthpart & "-" & daypart & "-" & yearpart<BR> end if<BR> if(dataformat = 2) then<BR> format_date = daypart & " " & months(monthpart) & "," & yearpart<BR> end if<BR> if(dataformat = 3) then<BR> format_date = months(monthpart) & " " & daypart & "," & yearpart<BR> end if<BR>end Function<BR>&#039;Function to format time string<BR>Function format_time(date,dataformat)<BR> hourpart = Hour(date)<BR> minutepart = Minute(date)<BR> secondpart = Second(date)<BR> format_time = hourpart & ":" & minutepart & ":" & secondpart<BR> end Function<BR><BR>Function GetPhisicalPath(string_to_transform)<BR> pos=InstrRev(LCase(Request.ServerVariables("PATH_T RANSLATED")),LCase(FormAction))<BR> GetPhisicalPath = Left(Request.ServerVariables("PATH_TRANSLATED"), pos-1 )&string_to_transform<BR> end Function<BR><BR><BR>Function escape_symbols(string_to_escape)<BR> string_to_escape_ret=Replace(string_to_escape,"&#0 39;","&#039;&#039;")<BR> escape_symbols=string_to_escape_ret<BR>end Function<BR><BR>&#039;----------Start Algorithm section------------<BR>%&#062;<BR><BR><BR>Thanks!

  4. #4
    sshine Guest

    Default Can anyone else help

    I&#039;m open for suggestions from anyone. Thanks!

  5. #5
    Join Date
    Dec 1969

    Default RE: Too vague to answer

    What is this code supposed to do, there is nothing in there about your database. <BR><BR>Is this your CGI-BIN.ASP?<BR><BR>It looks like your "automated" web studio didan&#039;t "import" the database functionality that you expected it to do.<BR><BR>Look back at;s solution to the problem. Start out small, make one page that asks a question. then another page that returns the results...<BR><BR>This is your question page (Question.html)<BR><BR>&#060;form action="searchdb.asp" method="post"&#062;<BR>&#060;b&#062;Search: &#060;/b&#062;&#060;input type=text name=txtSearch&#062;<BR><BR>&#060;input type=submit value="Search"&#062;<BR>&#060;/form&#062;<BR><BR>Then in the asp page you have:<BR><BR>&#060;%<BR>StrConnect="Driver={Micros oft Access Driver (*.mdb)}; DBQ=" & server.mappath("/folder/database.mdb")<BR>set ObjConn=Server.CreateObject("ADODB.Connection")<BR ><BR><BR>Qry = "Select * from tablename where thedbfield like &#039;%" & Request.Form("txtSearch") & "%&#039;;"<BR><BR>Set Rs=objConn.Execute(Qry)<BR>response.write("&#060;t able&#062;")<BR>Do while not Rs.EOF<BR> &#039; some code to display the desired fields.<BR> for i = 0 to rs.fields.count - 1<BR> response.write ("&#060;tr&#062;&#060;td&#062;" & rs(rs.fields(i).name) & "&#060;/td&#062;&#060;/tr&#062;")<BR> next<BR>rs.movenext<BR>Loop<BR>response.write("&#0 60;/table&#062;")<BR>Rs.Close<BR>Set Rs=Nothing<BR>%&#062;<BR><BR>What this will do is, it will take the text that you have entered, search the fields for that text, then display those values in a table. Work with that until you find a solution that works for your issue.<BR><BR>-- Whol<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts