Category Archives: ASP.NET

<%@ Page Language=”VB” AutoEventWireup=”False”
EnableSessionState=”False” EnableViewState=”False” %>
<%@ Import Namespace=”System.Data” %>
<%@ Import Namespace=”System.Data.Odbc” %>

<%
Dim ConnStr As String = “Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=test;uid=root;pwd=passwordhere;option=3″
Dim con As OdbcConnection = New OdbcConnection(ConnStr)
Dim cmd As OdbcCommand = New OdbcCommand(“SELECT * FROM Names”, con)
con.Open()
dgrAllNames.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection Or CommandBehavior.SingleResult)
dgrAllNames.DataBind()
%>

<html>
<head>
<title>Displaying Records from MySQL ‘Names’ table</title>
<style>
body { font: 100% Verdana; }
</style>
</head>
<body>

<p align=”center”>All records in the ‘Names’ table:</p>

<asp:DataGrid ID=”dgrAllNames” HorizontalAlign=”Center”
CellPadding=”3″ Runat=”server” />

</body>
</html>

<%
response.ContentType="text/xml"
response.Write("<?xml version='1.0' encoding='ISO-8859-1'?>")
response.Write("<note>")
response.Write("<from>Jani</from>")
response.Write("<to>Tove</to>")
response.Write("<message>Remember me this weekend</message>")
response.Write("</note>")
%>
Getting XML From a Database
<%
response.ContentType = "text/xml"
set conn=Server.CreateObject("ADODB.Connection")
conn.provider="Microsoft.Jet.OLEDB.4.0;"
conn.open server.mappath("/db/database.mdb")
sql="select fname,lname from tblGuestBook"
set rs=Conn.Execute(sql)rs.MoveFirst()response.write("<?xml version='1.0' encoding='ISO-8859-1'?>")
response.write("<guestbook>")
while (not rs.EOF)
  response.write("<guest>")
  response.write("<fname>" & rs("fname") & "</fname>")
  response.write("<lname>" & rs("lname") & "</lname>")
  response.write("</guest>")
  rs.MoveNext()
wendrs.close()
conn.close()
response.write("</guestbook>")
%>

file.aspx
<%@ Page Language=”VB” AutoEventWireup=”false” CodeFile=”Registration.aspx.vb” Inherits=”Registration” %> Read More »