Hi there, I'm a beginner in ASP.NET with VB and I'm stuck on problem with a SQL query. I'd like to ask you for advice what does my page or config file miss.
thats how my form looks like
<form id="form1" runat="server">
<div style="margin: 0 auto; width: 180px;">
<asp:Label Width="100px" ID="lblJmeno" runat="server" Text="Jméno:"></asp:Label>
<asp:Textbox ID="txtJmeno" runat="server"></asp:Textbox>
<br />
<asp:Label withd="100px" ID="lblHeslo" runat="server" Text="Heslo:"></asp:Label>
<asp:TextBox ID="txtHeslo" runat="server" TextMode="Password"></asp:TextBox>
<br />
<asp:Button ID="cmdOdeslat" runat="server" Text="Přihlásit" onclick="LogIn"> </asp:Button>
</div>
<asp:Label ID="lblStatus" runat="server" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label>
</form>
this is how my *aspx.vb file looks like
Partial Class _Default
Inherits System.Web.UI.Page
Public Sub LogIn(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdOdeslat.Click
Dim connStr As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"
Dim sqlconnet As Data.SqlClient.SqlConnection
Dim MyComm As Data.SqlClient.SqlCommand
sqlconnet = New Data.SqlClient.SqlConnection()
sqlconnet.ConnectionString = connStr
MyComm = New Data.SqlClient.SqlCommand("", sqlconnet)
MyComm.CommandType = Data.CommandType.Text
MyComm.CommandText = "SELECT * FROM identifikace WHERE (identifikacni_kod =’" & txtJmeno.Text & "‘) AND (heslo = ‘" & txtHeslo.Text & "‘) "
sqlconnet.Open()
Dim result As Data.SqlClient.SqlDataReader = MyComm.ExecuteReader(Data.CommandBehavior.CloseConnection)
If result.HasRows = False Then
lblStatus.Text = "Heslo nebo jméno se neshoduje s údaji v databázi!"
Else
Session("jmeno") = txtJmeno.Text
Response.Redirect("success.aspx")
End If
result.Close()
End Sub
End Class
Should be working now, sorry for post, but I found syntax errors by reading source code here, not in my editor *FACEPALM*