|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi
I just started to learn net and I am getting this error. I have to make a login page to redirect them to a different page after successful login, how can I do that. BC30289: Statement cannot appear within a method body. End of method assumed. ================================================== ============== Function GetUser(ByVal userName As String, ByVal userPassword As String) As System.Data.DataSet Dim connectionString As String = "server='(local)'; trusted_connection=true; database='Users'" Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionStri ng) Dim queryString As String = "SELECT [UserInfo].* FROM [UserInfo] WHERE (([UserInfo].[UserName] = @UserName) AN"& _ "D ([UserInfo].[UserPassword] = @UserPassword))" Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand dbCommand.CommandText = queryString dbCommand.Connection = dbConnection Dim dbParam_userName As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter dbParam_userName.ParameterName = "@UserName" dbParam_userName.Value = userName dbParam_userName.DbType = System.Data.DbType.String dbCommand.Parameters.Add(dbParam_userName) Dim dbParam_userPassword As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter dbParam_userPassword.ParameterName = "@UserPassword" dbParam_userPassword.Value = userPassword dbParam_userPassword.DbType = System.Data.DbType.String dbCommand.Parameters.Add(dbParam_userPassword) Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter dataAdapter.SelectCommand = dbCommand Dim dataSet As System.Data.DataSet = New System.Data.DataSet dataAdapter.Fill(dataSet) Return dataSet Sub LoginBtn_Click(Sender As Object, E As EventArgs) If Page.IsValid Then Dim userDS As New System.Data.DataSet userDS = GetUser(UserName.Text, UserPass.Text) If userDS.Tables(0).Rows.Count = 1 Then FormsAuthentication.RedirectFromLoginPage(UserName .Text, true) Else Msg.Text = "Invalid Credentials: Please try again" End If End If End FunctionSub LoginBtn_Click(Sender As Object, E As EventArgs) If Page.IsValid Then If (UserName.Text = "jdoe@somewhere.com") And (UserPass.Text = "password") Then FormsAuthentication.RedirectFromLoginPage(UserName .Text, true) Else Msg.Text = "Invalid Credentials: Please try again" End If End If End Sub ================================================== =================== |
|
#2
|
|||
|
|||
|
It's a little hard to read the code (I would suggest enclosing your code within [ code ] [ /code ] blocks... It makes it tons easier to read.
My suggestion would be that the problem is caused by the "End Function" in your code. You're trying to close off a Sub-Routine by using a End-Of-Function call. Try changing that to "End Sub". HTH.
__________________
____________________________________________ Developer Shed Weekly Writer | DevArticles Forum Moderator Build Your Own KlipFolio Klip With PHP FrankManno.com - Under Construction Design Interactive Group - Under Construction |
|
#3
|
|||
|
|||
|
For ASP.NET beginners (like me):
I'm trying to migrate "easily" my ASP pages to ASPX pages. Of course, I found the error below: BC30289: Statement cannot appear within a method body. End of method assumed. This erros occurs becaus my Subs and Functions are between tags <% and %>. For example: <% function Calc(x,y) Calc = y * x end function %> The simple way to pass this problem was: Move the code of Subs and Functions between tags below: <script runat="server" language="vb"> function Calc(x,y) Calc = y * x end function </script> Regards. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > .NET Development > Help With This Error |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|