.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 24th, 2004, 04:37 PM
learn.net learn.net is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 1 learn.net User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Help With This Error

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
================================================== ===================

Reply With Quote
  #2  
Old June 29th, 2004, 11:03 AM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
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

Reply With Quote
  #3  
Old August 19th, 2004, 03:53 PM
cwlo cwlo is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 1 cwlo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Lightbulb BC30289: Statement cannot appear within a method body. End of method assumed.

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.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > Help With This Error


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT