从Visual Web Developer到SQL Server Express数据库的连接字符串,用于登录屏幕

时间:2013-12-29 08:30:48

标签: html asp.net sql sql-server-express

我正在尝试使用Visual WebDeveloper aspx页面和SQL Server Express创建一个简单的登录屏幕。

我的SQL Server名称为SPAZZ\SQLEXPRESS

我有一个名为H2H的数据库和一个名为tblUserUser的数据库中的表。在tblUserUser表格内,我有2列sUserNamesPassword

在正面.aspx页面上,我有2个文本框,这里有一个按钮代码

 <tr>
 <td colspan="2">&nbsp;</td>
 <td colspan="2">User name:</td>
 <td colspan="2"><asp:TextBox name="txtUserName" tabIndex="1" ID="txtUserName" runat="server"></asp:TextBox></td>
 <td colspan="2"></td>
 </tr>     

 <tr>
 <td colspan="2">&nbsp;</td>
 <td colspan="2"><label>Password :</label></td>
 <td colspan="2"><asp:TextBox ID="txtPassword" runat="server" TextMode=Password></asp:TextBox></td>
 <td colspan="2"></td>     
 </tr>     

 <tr>
 <td colspan="2"></td>
 <td colspan="2">&nbsp;</td>
 <td colspan="2"><asp:Button class="button" ID="Button1" runat="server" Text="Log In"/></td>
 <td colspan="2">&nbsp;</td>
 </tr>

这是我在.aspx.vb页面上的代码

'这就是我认为导入问题的地方

Imports System.IO
Imports System.Data.SqlClient
Imports Microsoft.SqlServer
Imports H2H.Database.Connection.DataConnector

'and this is the rest of the code 
Partial Class Login1
    Inherits System.Web.UI.Page

    Dim oDB As New H2H.Database.Connection.DataConnector

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim oReader As SqlDataReader
        Dim sSQL As String

        sSQL = "SELECT * FROM tblUserUser where sUserName = '" & txtUserName.Text & "' and sPassword = '" & txtPassword.Text & "'"
        oReader = oDB.getData(sSQL)
        If oReader Is Nothing Then

        Else
            If oReader.Read Then
                Response.Write("<script language='javascript' type='text/javascript'>")
                Response.Write("alert('it workd now youl go to next page!');")
                Response.Write("</script>")
                Response.Write("<script language='javascript' type='text/javascript'>")
                'this is the next page
                'Response.Write("document.location='HomePage.aspx?sUser=" & oReader.Item("UserFullName").ToString & " " & oReader.Item("sSurname").ToString & "&sUserID=" & oReader.Item("PkiRekorkId").ToString & "'")
                Response.Write("</script>")

            End If
        End If

        oReader.Close()

我不知道我做错了什么,我一直在谷歌上搜索,无法找到答案请帮助

0 个答案:

没有答案