Skip to content

Instantly share code, notes, and snippets.

@Lucent
Created November 30, 2019 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lucent/0ad9854e916544e435a35b258e7cbcfe to your computer and use it in GitHub Desktop.
Save Lucent/0ad9854e916544e435a35b258e7cbcfe to your computer and use it in GitHub Desktop.
Compare the length of two Wikipedia articles
<%@ Page EnableViewState="false" EnableEventValidation="false" Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language="VB" runat="server">
Sub Page_Load(Src as object, E as EventArgs)
End Sub
Sub btnRunQuery_OnClick(Sender As Object, E As EventArgs)
Dim objConnection As OleDbConnection
Dim objCommand As OleDbCommand
Dim objDataReader As OleDbDataReader
Dim strSQLQuery As String
objConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & Server.MapPath("Database2.accdb") & ";")
strSQLQuery = "SELECT * FROM wiki WHERE (title='" & wikione.Text & "' OR title='" & wikitwo.Text & "')"
objCommand = New OleDbCommand(strSQLQuery, objConnection)
objConnection.Open()
objDataReader = objCommand.ExecuteReader(CommandBehavior.CloseConnection)
' lblSQLCommandLabel.Text = strSQLQuery
FightGrid.DataSource = objDataReader
FightGrid.DataBind()
End Sub
</script>
<html>
<head>
<title>Wiki Fight</title>
</head>
<body>
<form method="get" runat="server">
Wiki Fight:
<asp:TextBox id="wikione" runat="server" />
<asp:TextBox id="wikitwo" runat="server" />
<asp:Button type="submit" id="btnRunQuery" text="Fight!" OnClick="btnRunQuery_OnClick" runat="server" />
</form>
<asp:label id="lblSQLCommandLabel" runat="server" />
<asp:DataGrid id="FightGrid" runat="server"
cellspacing="1"
cellpadding="2"
HeaderStyle-Font-Bold="True"
/>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment