Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to specify certain name of the data from mysql database

Status
Not open for further replies.

Mentos123

Programmer
Feb 8, 2007
9
MY
Hi all,
really need your help. I am doing asp.net website(login page) using VB.net script. but i face some problem here. i can access mysql db, but the problem is that i would like to check whether the login id and pwd the user key in is valid or not..but when i click at the submit button, the error keep on coming out saying:No data exists for the row/column.
Below is my coding.. plssss.. can someone please help.. it is quite urgent..

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

<%

IF request.querystring("step") = "2" THEN

Dim str_Username = Request.Form ("loginid")
Dim str_Password = Request.Form ("password")

Dim ConnStr As String = "Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=DBName;uid=root;pwd=password;option=3"
Dim con As OdbcConnection = New OdbcConnection(ConnStr)
Dim cmd As OdbcCommand = New OdbcCommand("SELECT * FROM login WHERE sLoginID = '" & str_Username & "' AND sPassword = '" & str_Password & "'", con)
con.Open()

Dim rsrecord As OdbcDataReader = cmd.ExecuteReader()


If (rsrecord("sType"))="exp" Then 'This is the error part
Response.Redirect("Export.aspx")
ElseIf (rsrecord("sType"))="imp" Then
Response.Redirect("import.aspx")
Else
Response.Write("<script language='JavaScript'>alert('Invalid Login ID or Password!!!');</script>")
End If
cmd.ExecuteNonQuery()
con.Close()

End If



%>


<html>
<head>
<title>Login validation</title>
</head>

<body>
<form action="Login.aspx?step=2" method="post" name="myForm">
<table width="40%" border="0" align="center">
<tr>
<td width="35%" bordercolor="#FFFFFF"> <div align="left"><font color="#666666" size="2" face="Verdana, Arial, Helvetica, sans-serif">Login ID: </font></div></td>
<td width="8%" bordercolor="#FFFFFF"><font color="#666666" size="2" face="Verdana, Arial, Helvetica, sans-serif">:</font></td>
<td width="46%" bordercolor="#FFFFFF"> <input type="text" name="loginid" maxlength="20" size="20" class="texbox">
</td>
</tr>
<tr>
<td colspan="3" bordercolor="#FFFFFF">&nbsp;</td>
</tr>
<tr>
<td width="35%" bordercolor="#FFFFFF"><div align="left"><font color="#666666" size="2" face="Verdana, Arial, Helvetica, sans-serif">Password:</font></div></td>
<td width="8%" bordercolor="#FFFFFF"><font color="#666666" size="2" face="Verdana, Arial, Helvetica, sans-serif">:</font></td>
<td width="46%" bordercolor="#FFFFFF"> <input type="password" name="password" size="20" maxlength="20" class="texbox"></td>
</tr>
<tr>
<td colspan="3" bordercolor="#FFFFFF">&nbsp;</td>
</tr>
<tr>
<td colspan="5" align="center" bordercolor="#FFFFFF"><input type="submit" name="Submit" value="Login" class="button"><input type="reset" name="Reset" value="Reset" class="button">

</td>
</tr>

</table>
</form>


</body>
</html>


 
The error is happening because you are getting no rows back from the sql you are running.
 
Thank you so much for your reply.. i really appriciate it.. but what do you mean that getting no rows back from the sql you are running? Is it meaning that the particular database table that i m looking for has no data inside(is an empty table?)

But as you know i already enter two rows of data in that table.. the data that i enter are:


sLogin sPassword sType
test1 importpwd import
test2 exportpwd export

can you please explain more detail for me.. coz i really have no idea what is the error abt.. btw, is my coding below correct? any problem with it?

Dim rsrecord As OdbcDataReader = cmd.ExecuteReader()


If (rsrecord("sType"))="exp" Then 'This is the error part
Response.Redirect("Export.aspx")
ElseIf (rsrecord("sType"))="imp" Then
Response.Redirect("import.aspx")
Else
Response.Write("<script language='JavaScript'>alert('Invalid Login ID or Password!!!');</script>")
End If
cmd.ExecuteNonQuery()
con.Close()

End If


Thank you so much..
 
The SQL query that you are running doesn't return any results. It doesn't mean that the whole table is empty, but for the variabels you passed in, no results exist. In your scenario, that will mean either the username or password is incorrect.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top