How may I create and debugg a server script file in a website in Visual Studio 2008?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I created a asp file in a website in visual studio, with <span style="font-size:xx-small oneline of code
<%response.write(<span style="font-size:x-small; color:#a31515 <span style="font-size:x-small; color:#a31515 "6666"<span style="font-size:x-small ) %>
merely to write some numbers for testing. However Im not able to get it from another aspx page with ajax.
<div style="color:Black;background-color:White; <pre>
<span style="background-color:Yellow; <%<span style="color:Blue; @ <span style="color:#A31515; Page <span style="color:Red; Language<span style="color:Blue; =<span style="color:Blue; "VB" <span style="color:Red; AutoEventWireup<span style="color:Blue; =<span style="color:Blue; "false" <span style="color:Red; CodeFile<span style="color:Blue; =<span style="color:Blue; "Default.aspx.vb" <span style="color:Red; Inherits<span style="color:Blue; =<span style="color:Blue; "_Default" <span style="background-color:Yellow; %>

<span style="color:Blue; <!<span style="color:#A31515; DOCTYPE <span style="color:Red; html <span style="color:Red; PUBLIC <span style="color:Blue; "-//W3C//DTD XHTML 1.0 Transitional//EN" <span style="color:Blue; "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"<span style="color:Blue; >

<span style="color:Blue; <<span style="color:#A31515; html <span style="color:Red; xmlns<span style="color:Blue; =<span style="color:Blue; "http://www.w3.org/1999/xhtml"<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; head <span style="color:Red; runat<span style="color:Blue; =<span style="color:Blue; "server"<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; title<span style="color:Blue; ><span style="color:Blue; </<span style="color:#A31515; title<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; script <span style="color:Red; type<span style="color:Blue; =<span style="color:Blue; "text/javascript"<span style="color:Blue; >
<span style="color:Blue; function loadXMLDoc()
{
<span style="color:Blue; var xmlhttp;
<span style="color:Blue; if (window.XMLHttpRequest) {<span style="color:Green; // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = <span style="color:Blue; new XMLHttpRequest();
}
<span style="color:Blue; else {<span style="color:Green; // code for IE6, IE5
xmlhttp = <span style="color:Blue; new ActiveXObject(<span style="color:#A31515; "Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = <span style="color:Blue; function() {
<span style="color:Blue; if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById(<span style="color:#A31515; "myDiv").innerHTML = xmlhttp.responseText;
}
}

xmlhttp.open(<span style="color:#A31515; "GET", <span style="color:#A31515; "getAccCount.asp?t=" + Math.random(), <span style="color:Blue; true);

xmlhttp.send();
}
<span style="color:Blue; </<span style="color:#A31515; script<span style="color:Blue; >

<span style="color:Blue; </<span style="color:#A31515; head<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; body<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; div <span style="color:Red; id<span style="color:Blue; =<span style="color:Blue; "myDiv"<span style="color:Blue; ><span style="color:Blue; <<span style="color:#A31515; h2<span style="color:Blue; >Let AJAX change this text<span style="color:Blue; </<span style="color:#A31515; h2<span style="color:Blue; ><span style="color:Blue; </<span style="color:#A31515; div<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; button <span style="color:Red; type<span style="color:Blue; =<span style="color:Blue; "button" <span style="color:Red; onclick<span style="color:Blue; =<span style="color:Blue; "loadXMLDoc()"<span style="color:Blue; >Change Content<span style="color:Blue; </<span style="color:#A31515; button<span style="color:Blue; >


<span style="color:Blue; </<span style="color:#A31515; body<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; html<span style="color:Blue; >
[/code]
<span style="font-size:x-small <span style="font-size:x-small Secondly, is the following correct syntax to read one record from the database in the server script code?
<span style="font-size:x-small <span style="font-size:x-small
<div style="color:Black;background-color:White; <pre>
<%
response.expires=-1

sql = <span style="color:#A31515; "SELECT [AccCount] FROM [RGRE_DB].[dbo].[aDashboard_AccCount_View]"

<span style="color:Blue; set conn=Server.CreateObject(<span style="color:#A31515; "ADODB.Connection")
conn.open <span style="color:#A31515; "PROVIDER=SQLOLEDB;DATA SOURCE=rrsql;UID=sp_dashboard;PWD=abc123!;DATABASE=RGRE_DB "

<span style="color:Blue; set rs=Server.CreateObject(<span style="color:#A31515; "ADODB.recordset")
rs.Open sql,conn

<span style="color:Blue; do <span style="color:Blue; until rs.EOF
<span style="color:Blue; for <span style="color:Blue; each x <span style="color:Blue; in rs.Fields
response.write( x.AccCount )
<span style="color:Blue; next
rs.MoveNext
<span style="color:Blue; loop
%>
[/code]


View the full article
 
Back
Top