ASP VBSCRIPT MS SQL SERVER connection - sql-server

How to fix database connection? I'm moving website from one server to another.
This is what I've got in Connections file:
<%
' FileName="Connection_odbc_conn_dsn.htm"
' Type="ADO"
' DesigntimeType="ADO"
' HTTP="true"
' Catalog=""
' Schema=""
Dim MM_**_STRING
MM_**_STRING = "Driver={SQL Server};Server=localhost;Database=mssql0_***_1;Uid=mssql0_***_1;Pwd=********;"
%>
And this is asp file:
<%#LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include virtual="/Connections/**.asp" -->
<%
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL")
If Request.QueryString <> "" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
MM_valUsername = CStr(Request.Form("userName"))
If MM_valUsername <> "" Then
Dim MM_fldUserAuthorization
Dim MM_redirectLoginSuccess
Dim MM_redirectLoginFailed
Dim MM_loginSQL
Dim MM_rsUser
Dim MM_rsUser_cmd
MM_fldUserAuthorization = "userAccess"
MM_redirectLoginSuccess = "/welcome.asp"
MM_redirectLoginFailed = "/index.asp?error=Incorrect+Login,+Please+try+again"
MM_loginSQL = "SELECT userName, userPassword, userFirstName"
If MM_fldUserAuthorization <> "" Then MM_loginSQL = MM_loginSQL & "," & MM_fldUserAuthorization
MM_loginSQL = MM_loginSQL & " FROM users WHERE userName = ? AND userPassword = ?"
Set MM_rsUser_cmd = Server.CreateObject ("ADODB.Command")
MM_rsUser_cmd.ActiveConnection = MM_**_STRING
MM_rsUser_cmd.CommandText = MM_loginSQL
I've got error '80004005' in line 24. What is wrong? Is it a problem with database connection?

Related

Putting a new item in to the calendar overwrites the other item inside

Hello can someone please tell me what could be the problem in my calendar. So let me explain whats happening. So first im trying to make a scheduler application and im using a WPF scheduler in VB, so to begin with, the tab of a calendar needs to display 3 items (Subject, Professor Name, Courses) so what i need to do is to choose a room first and then drag a subject name from the listbox (like this Sample1) and then next i need to drag a professors name (Sample2) and then heres where the problems starts
So it already displays two items (Subject and Professor) now i need to drag an item from Course listbox, but the problem is whenever I put a course to the tab of a calendar, it becomes like this instead
So the goal here is to show 3 dragged items but instead, it only shows 2 and the course is overwriting the name of the subject. Please help me, thank you! If you want to see the whole codes, heres the link https://drive.google.com/file/d/1fWKisPr9qDh54B4EMdwWJbY3KFgi_xfc/view?usp=sharing
Heres the code of where you can drag the items
'Dragging Data to Calendar
Sub Add_list_item(ByVal list As String)
Delay.Delay(1)
Dim count = 0
For Each item As CalendarItem In Calendar1.GetSelectedItems()
count += 1
If count > 1 Then
Return
Else
Dim get_item_end_time As DateTime = item.EndDate.AddHours(2)
get_item_end_time = get_item_end_time.AddMinutes(30)
Dim item_start_time = item.StartDate
Dim item_end_time = get_item_end_time
Dim item_tooltip = item.StartDate.ToString()
Dim start_time = item.StartDate.ToString("HH:mm tt")
Dim end_time = item.EndDate.ToString("HH:mm tt")
Dim dat_start As Date = item_tooltip
Dim ci As CultureInfo = CultureInfo.CreateSpecificCulture("en-US")
Dim dtfi As DateTimeFormatInfo = ci.DateTimeFormat
dtfi.AbbreviatedDayNames = {"Sun", "1", "2", "3", "4",
"5", "6"}
Dim output_start As String = String.Format(ci, "{0:ddd}", dat_start.AddDays(0))
Dim item_text = CStr(item.Text)
Dim parts As String() = item_text.Split(New String() {Environment.NewLine},
StringSplitOptions.None)
Dim get_item_total_hours = (item.EndDate - item.StartDate).TotalHours
Dim get_start_time As DateTime
Dim get_end_time As DateTime
If get_item_total_hours = 1 Then
get_start_time = item.StartDate.AddMinutes(-30)
get_end_time = item.EndDate.AddMinutes(30)
ElseIf get_item_total_hours = 1.5 Then
get_start_time = item.StartDate.AddHours(-1)
get_end_time = item.EndDate.AddHours(1)
ElseIf get_item_total_hours = 2 Then
get_start_time = item.StartDate.AddHours(-1).AddMinutes(-30)
get_end_time = item.EndDate.AddHours(1).AddMinutes(30)
ElseIf get_item_total_hours = 2.5 Then
get_start_time = item.StartDate.AddHours(-2)
get_end_time = item.EndDate.AddHours(2)
ElseIf get_item_total_hours = 3 Then
get_start_time = item.StartDate.AddHours(-2).AddMinutes(-30)
get_end_time = item.EndDate.AddHours(2).AddMinutes(30)
ElseIf get_item_total_hours = 3.5 Then
get_start_time = item.StartDate.AddHours(-3)
get_end_time = item.EndDate.AddHours(3)
ElseIf get_item_total_hours = 4 Then
get_start_time = item.StartDate.AddHours(-3).AddMinutes(-30)
get_end_time = item.EndDate.AddHours(3).AddMinutes(30)
ElseIf get_item_total_hours = 4.5 Then
get_start_time = item.StartDate.AddHours(-4)
get_end_time = item.EndDate.AddHours(4)
ElseIf get_item_total_hours = 5 Then
get_start_time = item.StartDate.AddHours(-4).AddMinutes(-30)
get_end_time = item.EndDate.AddHours(4).AddMinutes(30)
ElseIf get_item_total_hours = 5.5 Then
get_start_time = item.StartDate.AddHours(-5)
get_end_time = item.EndDate.AddHours(5)
ElseIf get_item_total_hours = 6 Then
get_start_time = item.StartDate.AddHours(-5).AddMinutes(-30)
get_end_time = item.EndDate.AddHours(5).AddMinutes(30)
End If
If (ListBox1_Instructor.Items.Contains(list) = True) Then
Call Check_if_instructor(list)
End If
If parts.Count >= 3 Then
If (instructor_name = True) Then
Call Get_instructor_code(instructor_gender + list)
Call Get_course_name(corSec_id)
Call checkInstructorSchedule(start_time, end_time, output_start, instructor_id)
If (instructor_name = True) Then
If instructor_gender = "Male" Then
instructor_gender = "Mr. "
Else
instructor_gender = "Ms. "
End If
If item.Text <> "" Then
item.Text = parts(0) + vbNewLine + vbNewLine + instructor_gender + list
item.ApplyColor(Color.RoyalBlue)
End If
instructor_name = False
End If
Else
item.ApplyColor(Color.RoyalBlue)
item.Text = list + vbNewLine + vbNewLine + parts(2) + vbNewLine + vbNewLine
End If
ElseIf parts.Count = 1 Then
If (instructor_name = True) Then
Call Get_instructor_code(instructor_gender + list)
Call Get_course_name(corSec_id)
Call checkInstructorSchedule(start_time, end_time, output_start, instructor_id)
If (instructor_name = True) Then
If instructor_gender = "Male" Then
instructor_gender = "Mr. "
Else
instructor_gender = "Ms. "
End If
If item.Text <> "" Then
item.Text = parts(0) + vbNewLine + vbNewLine + instructor_gender + list
item.ApplyColor(Color.RoyalBlue)
End If
instructor_name = False
End If
Else
item.ApplyColor(Color.RoyalBlue)
item.Text = list + vbNewLine + vbNewLine + parts(parts.Count - 1) + vbNewLine + vbNewLine
End If
End If
Calendar1.Invalidate(item)
End If
Next
End Sub

Microsoft VBScript runtime error '800a01a8'

I have website which is working on my one server now I have migrated to another server changed the connection string. But one weird thing is some pages working fine but some page show me " page can not be displayed error message. I am new in VBscript Can anyone help me what am missing"
Below is the code of page which is not working on new server but working on old server
Microsoft VBScript runtime error '800a01a8' : object required
<%#LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<% if session("MM_Username") = "" or isnull(session("MM_Username")) then
response.redirect("/login.asp")
end if
%>
<%
Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd
Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId
Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Update Record: set variables
If (CStr(Request("MM_update")) = "form1" And CStr(Request("MM_recordId")) <> "") Then
MM_editConnection = MM_v3_STRING
MM_editTable = "dbo.custMessage"
MM_editColumn = "id"
MM_recordId = "" + Request.Form("MM_recordId") + ""
MM_editRedirectUrl = "Change.asp"
MM_fieldsStr = "textarea|value"
MM_columnsStr = "message|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_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
%>
<%
' *** Update Record: construct a sql update statement and execute it
If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then
' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
Next
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId
If (Not MM_abortEdit) Then
' execute the update
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 change__MMColParam
change__MMColParam = "1"
If (Request("MM_EmptyValue") <> "") Then
change__MMColParam = Request("MM_EmptyValue")
End If
%>
<%
Dim change
Dim change_numRows
Set change = Server.CreateObject("ADODB.Recordset")
change.ActiveConnection = MM_v3_STRING
change.Source = "SELECT * FROM dbo.custMessage WHERE id = " + Replace(change__MMColParam, "'", "''") + ""
change.CursorType = 0
change.CursorLocation = 2
change.LockType = 1
change.Open()
change_numRows = 0
%>
<%
'setup database connection
dim conn
set conn = server.CreateObject ("ADODB.Connection")
conn.ConnectionString = "Provider=SQLOLEDB;User ID=***;Password=***;Initial Catalog=heart_Test;Data Source=****;"
conn.Open
%>
So here is the answer.
Start Internet Services Manager.
Click Default Web Site, and then click Properties.
Double-click ASP in the Features pane.
Expand Behavior.
Click Enable Parent Paths.
Click True for Enable Parent Paths.
Click Apply.

In Visual Studio 2013 I simply want to pass data to a sql table using VB?

I am designing an application which is my forte but now have to code the back end. I am using Visual Studio 2013 with DevExpress and SQL Server 2014. It may be a simple question but I have struggled to find a straight answer anywhere. I have an asp.net book but I still cant find an answer. I think I have connected my whole solution with a connection string in that I can populate the tables and stored procedures into my dataclass. I simply want to add any user input into a table on SQL Server using a button with an onclick event. Surely it cant be that difficult but remember I am a bit of newbie so any help would be greatly appreciated. If there is any questions you need answered to assist then let me know. I am writing in VB script but am struggling to get it to work. Any advice would be appreciated. Thanks in advance!
Protected Sub btnAddNewSource_Click(sender As System.Object, e As EventArgs) Handles btnAddNewSource.Click
'ErrDetails.Text = ""
'ErrDetails.Visible = False
'FocusSet = False
'errCount = 0
'ErrDetails.Text = ""
'If txtSourceFunding.Text = "" Then
' ErrDetails.Text = ErrDetails.Text + "Did you enter the funding source?" + vbNewLine
' ErrDetails.Visible = True
' txtSourceFunding.Focus()
' FocusSet = True
' errCount = errCount + 1
'End If
'If txtContributionFunding.Text = "" Then
' ErrDetails.Text = ErrDetails.Text + "Did you enter the contribution?" + vbNewLine
' ErrDetails.Visible = True
' txtContributionFunding.Focus()
' FocusSet = True
' errCount = errCount + 1
'End If
'If cmbStatus.Value = -1 Then
' ErrDetails.Text = ErrDetails.Text + "Did you inform us of the status?" + vbNewLine
' ErrDetails.Visible = True
' cmbStatus.Focus()
' FocusSet = True
' errCount = errCount + 1
'End If
'If FocusSet = True Then
' ErrDetails.ForeColor = Drawing.Color.Red
' ErrDetails.Height = 20 * errCount
' ErrDetails.Visible = True
' Return
'End If
'Dim btnSource = (From o In dc1.Update_GrantApplicationCycleFunding Where o.GrantApplicationID = Session("CurrentProjectID").ToString).FirstOrDefault
'If Not IsNothing(btnSource) Then
' btnSource.GrantApplicationID = Session("CurrentProjectID")
' btnSource.GrantApplicationCycleFundingSource = txtSourceFunding.ToString
' btnSource.GrantApplicationCycleFundingContribution = txtContributionFunding.ToString
' btnSource.GrantApplicationCycleFundingStatusID = cmbStatus.ToString
' btnSource.GrantApplicationCycleFundingNotes = memFundingNotes.ToString
'Else
' Dim NewGrantApplicationCycleFundings As New GrantApplicationCycleFunding
' With NewGrantApplicationCycleFundings
' .GrantApplicationID = Session("CurrentProjectID")
' .GrantApplicationCycleFundingSource = txtSourceFunding.ToString
' .GrantApplicationCycleFundingContribution = txtContributionFunding.ToString
' .GrantApplicationCycleFundingStatusID = cmbStatus.ToString
' .GrantApplicationCycleFundingNotes = memFundingNotes.Text
' End With
' dc1.GrantApplicationCycleFundings.InsertOnSubmit(NewGrantApplicationCycleFundings)
' dc1.SubmitChanges()
' End If
'dc1.SubmitChanges()
Hey I have now managed to make the button add data to the datagrid. The big thing I missed was the declarations of the fields values at the bottom of the code and of course the databind! Never forget the correct DATABIND. You can adapt and use this in your own code if you are having similar problems! If you need help or explanation and I can help you then I will. Just add comment. Thanks
** ErrDetails.Text = ""
ErrDetails.Visible = False
FocusSet = False
errCount = 0
ErrDetails.Text = ""
If spnTotalEstimatedCost.Value <= 0 Then
ErrDetails.Text = ErrDetails.Text + "Please enter the cost." + vbNewLine
ErrDetails.Visible = True
If FocusSet = False Then
spnTotalEstimatedCost.Focus()
FocusSet = True
End If
errCount = errCount + 1
End If
If txtSourceFunding.Text = "" Then
ErrDetails.Text = ErrDetails.Text + "Please........?" + vbNewLine
ErrDetails.Visible = True
txtSourceFunding.Focus()
FocusSet = True
errCount = errCount + 1
End If
If spnContributionFunding.Value = 0 Then
ErrDetails.Text = ErrDetails.Text + "Please......" + vbNewLine
ErrDetails.Visible = True
spnContributionFunding.Focus()
FocusSet = True
errCount = errCount + 1
End If
If FocusSet = True Then
ErrDetails.ForeColor = Drawing.Color.Red
ErrDetails.Height = 20 * errCount
ErrDetails.Visible = True
Return
End If
Dim NewGrantApplicationMatchFundings As New GrantApplicationMatchFunding
With NewGrantApplicationMatchFundings
.GrantApplicationID = Session("CurrentProjectID")
.GrantApplicationMatchFundingName = txtSourceFunding.Text
.GrantApplicationMatchFundingContribution = spnContributionFunding.Value
.GrantApplicationMatchFundingStatus = cmbStatus.SelectedItem.Value
.GrantApplicationMatchFundingNotes = memFundingNotes.Text
End With
dc1.GrantApplicationMatchFundings.InsertOnSubmit(NewGrantApplicationMatchFundings)
dc1.SubmitChanges()
'End If
'dc1.SubmitChanges()
txtSourceFunding.Text = ""
spnContributionFunding.Value = ""
cmbStatus.Value = ""
memFundingNotes.Text = ""
grdFunding.DataBind()
Dim btnTotal = (From o In dc1.Select_GrantApplicationMatchFundingTotal(Session("CurrentProjectID").ToString)).FirstOrDefault
If Not IsNothing(btnTotal) Then
spnTotalMatchFunding.Text = btnTotal.TotalFunding
txtGrantFunding.Text = (spnTotalMatchFunding.Value / spnTotalEstimatedCost.Value) * 100
Else
spnTotalMatchFunding.Text = 0
txtGrantFunding.Text = 0
End If
Dim cafChange = (From o In dc1.GrantApplicationCostsAndFundings Where o.GrantApplicationID.ToString = Session("CurrentProjectID").ToString).FirstOrDefault
If Not IsNothing(cafChange) Then
cafChange.GrantApplicationID = Session("CurrentProjectID")
cafChange.GrantApplicationProjectCostsYear1 = spnTotalEstimatedCost.Value
cafChange.GrantApplicationMatchedFundingNotesYear1 = memNotesMatchFunding.Text
cafChange.GrantApplicationProjectRequestedYear1 = txtGrantFunding.Value
dc1.SubmitChanges()
Else
Dim NewGrantApplicationCostsAndFundings As New GrantApplicationCostsAndFunding
With NewGrantApplicationCostsAndFundings
.GrantApplicationID = Session("CurrentProjectID")
.GrantApplicationProjectCostsYear1 = spnTotalEstimatedCost.Value
.GrantApplicationMatchedFundingNotesYear1 = memNotesMatchFunding.Text
.GrantApplicationProjectRequestedYear1 = txtGrantFunding.Value
End With
dc1.GrantApplicationCostsAndFundings.InsertOnSubmit(NewGrantApplicationCostsAndFundings)
dc1.SubmitChanges()
End If
End Sub

Updating the table and displaying the current data

I am trying to update the table which is working but after updating I cannnot see the updated data on the form when I ho to next record and comeback eventhough it gets updated on sql server.
Here is my code
Try
cn = Connection.connectionstringESLC()
cn.Open()
Dim query As String
query = "Update [School Admin Aug 2012] SET NAME='" & txtName.Text & _
"' , ADDRESS = '" & txtAddress.Text & _
"' , [Alternate Email] = '" & txtEmail.Text & _
"' , [ADVISOR NAME] = '" & txtAdvName.Text & _
"' , [DEPT NAME] = '" & txtDept.Text & _
"' , PROGRAM = '" & txtDegree.Text & _
"' , DEGREE = '" & txtMajor.Text & _
"', MAJOR = '" & txtProgram.Text & _
"', [DATE ADMITTED] = '" & dtpAdmitted.Value & _
"', [ADMISSION DECISION] = '" & cmbAdmDecision.Text & _
"' , [ENROLLMENT STATUS] = '" & cmbEnrollment.Text & _
"', [CAMPUS] = '" & cmbCampus.Text & _
"' , [ADVISING SHEET DATE] = '" & dtpAdvshtdt.Value & _
"' , [GRADUATION DATE] = '" & dtpGrdDt.Value & _
"' , [CURRENT POSITION] = '" & txtCurrentPosition.Text & _
"' , [GRE] = '" & txtGRE.Text & _
"' , [SLLA] = '" & txtSLLA.Text & _
"' , [KYPT] = '" & txtKYPT.Text & _
"' , [COMMENT] = '" & txtComment.Text & _
"' WHERE [MNUMBER] = '" & txtMNumber.Text & "'"
cmd = New SqlCommand(query, cn)
cmd.ExecuteNonQuery()
cn.Close()
cn = Nothing
MsgBox("Record updated successfully")
loadinfo()
Catch ex As Exception
MsgBox(ex.Message)
End Try
' I am also running loadinfo() code on page_load function
Public Sub loadinfo()
Try
cn = Connection.connectionstringESLC()
cn.Open()
cmd = New SqlCommand("Select * from [School Admin Aug 2012]")
cmd.Connection = cn
da.SelectCommand = cmd
da.Fill(ds, "dbo.School Admin Aug 2012")
da.Dispose()
cmd.Dispose()
If i < ds.Tables(0).Rows.Count - 1 Then
txtMNumber.Text = ds.Tables(0).Rows(i).Item(0)
txtName.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(1)), " ", ds.Tables(0).Rows(i).Item(1))
' IIf(IsDBNull(ds.Tables(0).Rows(0).Item(2)), " ", ds.Tables(0).Rows(0).Item(2))
txtAddress.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(2)), " ", ds.Tables(0).Rows(i).Item(2))
txtEmail.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(3)), " ", ds.Tables(0).Rows(i).Item(3))
txtAdvName.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(4)), " ", ds.Tables(0).Rows(i).Item(4))
txtDept.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(5)), " ", ds.Tables(0).Rows(i).Item(5))
txtProgram.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(6)), " ", ds.Tables(0).Rows(i).Item("PROGRAM"))
txtDegree.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(7)), " ", ds.Tables(0).Rows(i).Item("DEGREE"))
txtMajor.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(8)), " ", ds.Tables(0).Rows(i).Item("MAJOR"))
dtpAdmitted.Value = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(9)), "12/31/9998", ds.Tables(0).Rows(i).Item(9))
cmbAdmDecision.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(10)), " ", ds.Tables(0).Rows(i).Item(10))
cmbEnrollment.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(11)), " ", ds.Tables(0).Rows(i).Item(11))
cmbCampus.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(12)), " ", ds.Tables(0).Rows(i).Item(12))
dtpAdvshtdt.Value = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(13)), "12/31/9998", ds.Tables(0).Rows(i).Item(13))
dtpGrdDt.Value = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(14)), "12/31/9998", ds.Tables(0).Rows(i).Item(14))
txtCurrentPosition.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(15)), " ", ds.Tables(0).Rows(i).Item(15))
txtGRE.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(16)), " ", ds.Tables(0).Rows(i).Item(16))
txtSLLA.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(17)), " ", ds.Tables(0).Rows(i).Item(17))
txtKYPT.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(18)), " ", ds.Tables(0).Rows(i).Item(18))
txtComment.Text = IIf(IsDBNull(ds.Tables(0).Rows(i).Item(19)), " ", ds.Tables(0).Rows(i).Item(19))
cn.Close()
cn = Nothing
ElseIf i < 0 Then
i = 0
Else
MsgBox("This is the last record")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Classic ASP returns the ID of the results in the URL

In a Classic ASP website and MSSQL database: When a search for data is completed the URL displays the ID of the results. eg sitename/Display_Results.asp?cboService=253&cboRegion=588. Where is the script or code that determines the return of the ID, is it in the page code or database stored procedures? I want to display the description of the Id in the URL.
<%# language="vbscript" codepage="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
sRoot = ""`
Function alert(msg,where)
%>
alert('<%="Message = "&msg&"\nWhere = "&where%>') <% end function
fFunction Ceiling(byval n) Dim iTmp, bErr
on error resume next
n = cdbl(n)
if err then bErr = true
on error goto 0
if bErr then Err.Raise 5000, "Ceiling Function", _
"Input must be convertible to a sub-type of double"
f = Floor(n)
if f = n then
Ceiling = n
Exit Function
End If
Ceiling = cInt(f + 1)
End Function
%>
<html>
<head>
<!--#include file="includes/scripts/Includes.asp"-->
<%
Call WriteServiceMetaData(objConn, strConn)
%>
<script type="text/javascript" src="includes/scripts/javascript.js"></script>
<script type="text/javascript" src="includes/scripts/pngfix.mod.js"></script>
<script type="text/javascript" src="includes/scripts/swfobject.js"></script>
<script type="text/javascript" src="swfobject/swfobject.js"></script>
<script type="text/javascript">
function showborder(idnew,argsnew){
var idnew = idnew;
var argsnew = argsnew;
if(argsnew == "on"){
document.getElementById(idnew).style.border='2px solid #759fb9';
}
else{
document.getElementById(idnew).style.border='';
}
}
</script>
<script type="text/javascript">
function showpng(idnew,argsnew){
var idnew = idnew;
var argsnew = argsnew;
if(argsnew == "on"){
document.getElementById(idnew).style.visibility='';
}
else{
document.getElementById(idnew).style.visibility='hidden';
}
}
</script>
<link rel="stylesheet" type="text/css" href="<%=sRoot%>css/universal.css">
</head>
<%
Dim maxResults
Dim DRCountry_ID, Country_Variable
Dim DRCounty_ID, County_Variable
Dim DRLocation, Location_Variable
Dim DRType_ID, DRType_ID_Array, Type_Variable, cType_Variable
Dim End_request, LUXSQL
Dim Query, Query_Result
Dim Page_Num, HOTSQL, HOTOFFER, Text, DRTube_ID, DRPrice_Min, DRPrice_Max, Tube_Variable, DRPrice, Price_Variable
Dim lCityID, lCountyID, lCountryID
set objRS = objConn.execute ("General_Admin_List")
maxResults = objRS("Num_Results")
objRS.Close
set objRS = nothing
'on error resume next
'Page_Num= clng(Request.QueryString("Page_Num"))
'if err.number <> 0 then
'Page_Num = 0
'end if
'on error goto 0
if strcomp(Request.ServerVariables("REQUEST_METHOD"), "POST", 1) = 0 then
on error resume next
if len(trim(Request.Form("HotOffer"))) > 0 then
iHotOffer = 1
else
iHotOffer = 0
end if
on error resume next
'Turn off error handling
company = trim(request.Form("company"))
if company = "Enter Name" then
company = ""
end if
if err.number <> 0 then
'If there is an error then the requested input is not a number
company = "null"
end if
err.clear
'Turn error handling back on
on error goto 0
lCountyID = clng(trim(Request.Form("cboRegion")))
if err.number <> 0 then
lCountyID = 0
end if
err.clear
lCountryID = clng(trim(Request.Form("cboCountry")))
if err.number <> 0 then
lCountryID = 0
end if
err.clear
lFeatureID = clng(trim(Request.Form("cboFeature")))
if err.number <> 0 then
lFeatureID = 0
end if
err.clear
lServiceID = clng(Request.Form("cboService"))
if err.number <> 0 or lServiceID < 1 then
lServiceID = 0
else
session("SearchServiceID") = lServiceID
end if
err.clear
lCityID = clng(Request.Form("cboCity"))
if err.number <> 0 or lCityID < 1 then
lCityID = 0
end if
sTypes = trim(Request.Form("asfTypes"))
session("searchTypes") = sTypes
on error goto 0
else
on error resume next
'Turn off error handling
company = trim(request.QueryString("company"))
if company = "Enter Name" then
company = ""
end if
if err.number <> 0 then
'If there is an error then the requested input is not a number
company = "null"
end if
err.clear
'Turn error handling back on
on error goto 0
on error resume next
if len(trim(Request.QueryString("HotOffer"))) > 0 then
iHotOffer = 1
else
iHotOffer = 0
end if
lCountyID = clng(trim(Request.QueryString("cboRegion")))
if err.number <> 0 then
lCountyID = 0
end if
err.clear
lCountryID = clng(trim(Request.QueryString("cboCountry")))
if err.number <> 0 then
lCountryID = 0
end if
err.clear
lFeatureID = clng(trim(Request.QueryString("cboFeature")))
if err.number <> 0 then
lFeatureID = 0
end if
err.clear
lServiceID = clng(Request.QueryString("cboService"))
if err.number <> 0 or lServiceID < 1 then
lServiceID = 0
else
session("SearchServiceID") = lServiceID
end if
err.clear
if request.QueryString("asfFeatures") <> "" then
lFeatureID = clng(Request.QueryString("asfFeatures"))
if err.number <> 0 or lFeatureID < 1 then
lFeatureID = 0
end if
err.clear
end if
lCityID = clng(Request.QueryString("CityID"))
if err.number <> 0 or lCityID < 1 then
lCityID = 0
end if
sTypes = trim(Request.QueryString("asfTypes"))
'Response.Write(sTypes)
session("searchTypes") = sTypes
on error goto 0
end if
if lCityID = 0 then
sCity = trim(Request.QueryString("City"))
if len(sCity) = 0 then
lCityID = 0
else
set objRS = objConn.execute ("City_Lookup '" & Replace(sCity, "'", "''") & "'")
if objRS.EOF then
lCityID = 999999
else
lCityID = objRS("City_ID")
lCountyID = objRS("County_ID")
lCountryID = objRS("Country_ID")
end if
objRS.Close
set objRS = nothing
end if
end if
'This below was commented out, seems to do nothing
' Not using location finder just yet
dim sURL
sURL = "Select_Location.asp?location=" & Server.URLEncode(trim(Request.QueryString("SLocation"))) & "&Search=" & Request.QueryString("Search")
sURL = sURL & "&Service=" & lServiceID
sURL = sURL & "&Types=" & sTypes
DRLocation = replace(trim(Request.QueryString("SLocation")), "'", "''")
if len(DRLocation) > 0 then ' and lCountryID = 0 then
set objRS = Server.CreateObject("ADODB.Recordset")
objRS.CursorLocation = 3
objRS.Open "City_Lookup '" & DRLocation & "'," & lCountyID & ", " & lCountryID, objConn
if objRS.RecordCount > 1 then
objRS.Close
objConn.close
response.Redirect(sURL)
end if
if not objRS.eof then
lCityID = clng(objRS("City_ID"))
lCountyID = clng(objRS("County_ID"))
else
objRS.Close
objRS.Open "County_Lookup '" & DRLocation & "', " & lCountryID, objConn
if objRS.RecordCount > 1 then
objRS.Close
objConn.close
response.Redirect(sURL)
end if
if not objRS.eof then
lCountyID = clng(objRS("County_ID"))
else
objRS.Close
objConn.close
response.Redirect(sURL)
end if
end if
objRS.Close
set objRS = nothing
end if
'This above was commented out, seems to do nothing
dim lSearchID
lSearchID = 0
if len(sTypes) > 0 then
Application.Lock()
if Application("LSG_SearchID") = "" then
lSearchID = 1
else
lSearchID = clng(Application("LSG_SearchID")) + 1
end if
Application("LSG_SearchID") = lSearchID
Application.UnLock()
objConn.execute "Value_Splitter '" & sTypes & "', ',', " & lSearchID
end if
objConn.CursorLocation = adUseClient
set objComm = Server.CreateObject("ADODB.Command")
set objComm.ActiveConnection = objConn
objComm.CommandText = "Search"
objComm.CommandType = adCmdStoredProc
objComm.Parameters.Append objComm.CreateParameter ("#City_ID", adInteger, adParamInput)
objComm.Parameters.Append objComm.CreateParameter ("#County_ID", adInteger, adParamInput)
objComm.Parameters.Append objComm.CreateParameter ("#Country_ID", adInteger, adParamInput)
objComm.Parameters.Append objComm.CreateParameter ("#Service_ID", adInteger, adParamInput)
objComm.Parameters.Append objComm.CreateParameter ("#Search_ID", adInteger, adParamInput)
objComm.Parameters.Append objComm.CreateParameter ("#Feature_ID", adInteger, adParamInput)
objComm.Parameters.Append objComm.CreateParameter ("#Specialist_Area", adBoolean, adParamInput, , iHotOffer)
objComm.Parameters.Append objComm.CreateParameter ("#ResultCount", adInteger, adParamOutput)
objComm.Parameters.Append objComm.CreateParameter ("#Company", adVarchar, adParamInput, 255)
if lCountryID > 0 then
objComm.Parameters("#Country_ID") = lCountryID
end if
if lCountyID > 0 then
objComm.Parameters("#County_ID") = lCountyID
end if
if lCityID > 0 then
objComm.Parameters("#City_ID") = lCityID
end if
if lServiceID > 0 then
objComm.Parameters("#Service_ID") = lServiceID
end if
if lFeatureID > 0 then
objComm.Parameters("#Feature_ID") = lFeatureID
end if
if lSearchID > 0 then
objComm.Parameters("#Search_ID") = lSearchID
end if
if company = "null" then
objComm.Parameters("#Company") = null
else
objComm.Parameters("#Company") = company
end if
'Query = "Search " & paramCity & ", " & paramCounty & ", " & paramCountry
'end if
'response.End()
'Set Query_Result = Server.CreateObject("ADODB.Recordset")
'Response.Write("Query"&Query)
set Query_Result = objComm.Execute()
lResultCount = objComm.Parameters("#ResultCount").value
lSearchCity = lCityID
if lServiceID > 0 then
SELECT_SQL = "Service_Get "& lServiceID
Set SELECT_SQL_RESULT = Server.CreateObject("ADODB.Recordset")
SELECT_SQL_RESULT.Open SELECT_SQL, ObjConn
do while not SELECT_SQL_RESULT.eof
service = SELECT_SQL_RESULT("service")
service_description = SELECT_SQL_RESULT("Service_Description")
SELECT_SQL_RESULT.MoveNext
Loop
SELECT_SQL_RESULT.Close
end if
'Get city (set email location) from search and put into cookie
if Request.QueryString("CityID") > 0 Then
GetCity = "getCity "&Request.QueryString("CityID")
Set GetCity_Result = Server.CreateObject("ADODB.Recordset")
GetCity_Result.Open GetCity, ObjConn
if not GetCity_Result.eof then
emailCity = GetCity_Result("City")
end if
Response.Cookies("LSG")("Location") = emailCity
Response.Cookies("LSG").Expires= DateAdd("d", Date(), 365)
end if
%>
<%
Dim SELECT_SQL, SELECT_SQL_RESULT
Dim Top_PAGECONTENT_Title, Top_PAGECONTENT_Content
Dim Bottom_PAGECONTENT_Title, Bottom_PAGECONTENT_Content
Dim page_name, url,sPath
sPath=""
url = request.ServerVariables("URL")
page_name = right(url, len(url) - instrrev(url, "/"))
SELECT_SQL = "Page_Content_Get '"& page_name &"'"
Set SELECT_SQL_RESULT = Server.CreateObject("ADODB.Recordset")
SELECT_SQL_RESULT.Open SELECT_SQL, ObjConn
do while not SELECT_SQL_RESULT.eof
If SELECT_SQL_RESULT("Position") = "Page Top" then
Top_PAGECONTENT_Title = SELECT_SQL_RESULT("Title")
Top_PAGECONTENT_Content = SELECT_SQL_RESULT("Content")
Top_PAGECONTENT_Content = Replace(Top_PAGECONTENT_Content, vbcrlf, "<br>")
end if
SELECT_SQL_RESULT.MoveNext
Loop
SELECT_SQL_RESULT.Close
%>
<body>
<div class="SiteContainer">
<!--#include file="includes/content/banner_rotator.asp"-->
<div class="LeftSiteContainer">
<!--#include file="includes/content/hdg_left.asp"-->
<!--#include file="includes/content/hdg_Header2.asp"-->
<div class="indexMainContainer">
<div id="mainLeftContent">
<div class="MainContent">
<%
if service = "" then
service = "Boat and Yacht products and services"
end if
if emailcity = "" then
emailcity = "Boat Chandlers Guide"
end if
%>
<%If not Query_Result.EOF Then%>
<span style="color:#1A59CD;"><h1><%=service%></h1></span>
<span style="color:#1A59CD;"><h2><%=Service_Description%></h2></span>
<div style="color:#666666; float:left; padding-top:8px;">Your search returned <span style="color:#1A59CD; font-weight:bold;"><%=lResultCount%></span> result<%if lResultCount > 1 then response.write "s" end if%> for <!--<%=emailcity%> to--> <%=service%> </div>
<div style="clear:both;"> </div>
<!--<h2><%=emailcity%> search results for <%=service%></h2>-->
<% else %>
<div style="clear:both;"></div>
<span style="color:#1A59CD;"><h1><%=emailcity%> <%=service%></h1></span>
<div class="search_no_results">
<strong>Sorry, there are currently no <%=service%> featured on <%=emailcity%> at this time.</strong>
</div>
<% End If %>
<%If not Query_Result.EOF Then
numResults = maxResults 'The Number of Results to Display on each page
count = lResultCount
dim Number_array, Total_Pages
Number_Array = split(((count-1) / numResults),".")
Total_Pages = count \ numResults
if count mod numResults > 0 then
Total_Pages = Total_Pages + 1
end if
%>
<%end if
If Query_Result.EOF Then%>
<div class="search_no_results">
<strong>Sorry, no results were found that match your search criteria.</strong>
</div>
<% End If
Dim count, strt, endd, numResults, tr_count
tr_count = 0
'-----------------------------------------------'
' Set the Number of the first record to display '
'-----------------------------------------------'
if not Query_Result.eof then
strt = cint(Request.queryString("results"))
if (strt = null) OR (strt <= 0) then
strt = 1
end if
endd = strt + numResults-1
if numresults = 1 then
Page_Num = strt
else
Page_Num = strt \ numresults
Page_Num = Page_Num + 1
end if
end if
count = 1
PageEnd = Page_Num * numResults
PageStart = PageEnd - 20
if PageEnd > lResultCount then
pageEnd = lResultCount
end if
if request.QueryString("st") = "" then
CurrentPageNumber = 1
else
CurrentPageNumber = request.QueryString("st")
end if
'How many on first number
FirstNum = numResults * (CurrentPagenumber - 1) - (numResults -1)
if clng(CurrentPageNumber) < clng(Total_Pages) then
if clng(Total_Pages - 1) = clng(CurrentPageNumber) then
high = CurrentPageNumber + 1
else
high = CurrentPageNumber + 2
end if
end if
'How many on last number
LastNum = numResults * (CurrentPagenumber + 1) - (numResults-1)
LastCount = ((Total_Pages - 1) * numResults) + 1
if lResultCount > 0 then%>
<DIV class="displayResultsPageNumberContainer">
<div class="displayResultsPrevious">
<% if Page_Num > 1 then %>
<A id="Page<%=PageNumber%>" style="color:#6b98b4;" href="Display_Results.asp?cboCountry=<%=lCountryID%>&cboFeature=<%=request.QueryString("cboFeature")%>&cboRegion=<%=lCountyID%>&cboService=<%=lServiceID%>&asfTypes=<%=sTypes%>&CityID=<%=lSearchCity%>&asfFeatures=<%=lFeatureID%><%if iHotOffer > 0 then response.Write("&HotOffer=Y") end if%>&results=<%=FirstNum%>&st=<%=CurrentPagenumber-1%>"><<Previous</A>
<% else %>
<% end if %>
</div>
<% if cint(Page_Num) < cint(Total_Pages) then
%>
<div style="float:right; margin-right:10px;"><A style="color:#6b98b4;" id="Page<%=PageNumber%>" href="Display_Results.asp?cboCountry=<%=lCountryID%>&cboFeature=<%=request.QueryString("cboFeature")%>&cboRegion=<%=lCountyID%>&cboService=<%=lServiceID%>&asfTypes=<%=sTypes%>&CityID=<%=lSearchCity%>&asfFeatures=<%=lFeatureID%><%if iHotOffer > 0 then response.Write("&HotOffer=Y") end if%>&st=<%=CurrentPagenumber+1%>&results=<%=LastNum%>">Next >></a></div>
<% end if %>
</DIV>
<%end if
Do Until Query_Result.EOF or count > endd
if (count >= strt) AND (count <= endd) then
Image_Query = "Advert_Images_Get "&Query_Result("Advert_ID")
Set Image_Query_Result = Server.CreateObject("ADODB.Recordset")
Image_Query_Result.Open Image_Query, ObjConn
if not Image_Query_Result.eof then
ImgThumb = replace(Image_Query_Result("Image_Name"),".jpg","_db_mid.jpg")
else
ImgThumb = "1pxSpacer.gif"
end if
%>
<div class="search_result_advert">
<% newCity = replace(Query_Result("City"),",","_") %>
<div class="search_result_advert_img">
<div><a title="View Advert - <%=Query_Result("Title")%>" href="<%=getFilename(newCity, Query_Result("Title"), Query_Result("Advert_ID"))%>"><img src="adverts_pics/<%=ImgThumb%>" alt="<%=Query_Result("Title")%>" border="0" /></a></div>
</div>
<div class="search_result_advert_details">
<div style="float:right;"><a style="color:#6b98b4;" title="View Advert - <%=Query_Result("Title")%>" href="<%=getFilename(newCity, Query_Result("Title"), Query_Result("Advert_ID"))%>">More Info</a></div>
<h3><a id="Result<%=Query_Result("Advert_ID")%>" title="View Advert - <%=Query_Result("Title")%>" href="<%=getFilename(newCity, Query_Result("Title"), Query_Result("Advert_ID"))%>"><%=ucase(TruncateString(Query_Result("Title"),30))%></a></h3>
<div style="margin-top:5px;"><%=TruncateString(Query_Result("Description"), 320)%></div>
</div>
</div>
<div style="margin-top:10px; height:5px;"></div>
<%
end if
count = count + 1
Query_Result.MoveNext
Loop
%>
<%if lResultCount > 0 then%>
<DIV class="displayResultsPageNumberContainer">
<div class="displayResultsPrevious">
<% if Page_Num > 1 then %>
<A style="color:#6b98b4;" id="Page<%=PageNumber%>" href="Display_Results.asp?cboCountry=<%=lCountryID%>&cboFeature=<%=request.QueryString("cboFeature")%>&cboRegion=<%=lCountyID%>&cboService=<%=lServiceID%>&asfTypes=<%=sTypes%>&CityID=<%=lSearchCity%>&asfFeatures=<%=lFeatureID%><%if iHotOffer > 0 then response.Write("&HotOffer=Y") end if%>&results=<%=FirstNum%>&st=<%=CurrentPagenumber-1%>"><< Previous</A>
<% else %>
<% end if %>
</div>
<!--<div class="displayResultsPageNumber">Displaying <b><%=PageStart%> - <%=PageEnd%> of <%=lResultCount%> Search Results for </b></div>-->
<% if cint(Page_Num) < cint(Total_Pages) then
%>
<div style="float:right; margin-right:10px;"><A style="color:#6b98b4;" id="Page<%=PageNumber%>" href="Display_Results.asp?cboCountry=<%=lCountryID%>&cboFeature=<%=request.QueryString("cboFeature")%>&cboRegion=<%=lCountyID%>&cboService=<%=lServiceID%>&asfTypes=<%=sTypes%>&CityID=<%=lSearchCity%>&asfFeatures=<%=lFeatureID%><%if iHotOffer > 0 then response.Write("&HotOffer=Y") end if%>&st=<%=CurrentPagenumber+1%>&results=<%=LastNum%>">Next >></a></div>
<% end if %>
</DIV>
<%end if%>
<br/>
<br/>
<div class="advanced_bg">
<div style="float:left;"><img src="images/img_advanced.jpg" alt="Advanced Search"/></div>
<div id="advanced_title"> <%=Top_PAGECONTENT_Title%></div>
<%=Top_PAGECONTENT_Content%>
</div>
</div>
<%
'<!--#include file="includes/content/hdg_right.asp"-->
%>
</div>
</div>
<div id="footer"><!--#include file="includes/content/hdg_Footer.asp"--> </div>
</div>
</body>
</html>
<!--#include file="includes/scripts/DatabaseConnectClose.asp"-->
without you showing the code, it would be difficult to determine exactly what is going on, but my best guess would that your form method is set to "get" and not "post".
it is for this reason all these value pairs are displaying in the URL.
In addition, the ID you are wanting to be there as well, is this perhaps currently in a hidden field??

Resources