Can't solve error codes

Closed
kdub - Mar 26, 2009 at 09:07 PM
 jigish - May 5, 2010 at 03:48 PM
Hello, How can I fix this code

' Add your comments here
Imports System.Data
Imports System.Data.OleDb

Imports System
Imports System.Net
Imports Microsoft.VisualBasic

Public Class clsDataLayer
' This function gets the user activity from the tblUserActivity
Public Shared Function GetUserActivity(ByVal Database As String) As dsUserActivity
' Add your comments here
Dim DS As dsUserActivity
Dim sqlConn As OleDbConnection
Dim sqlDA As OleDbDataAdapter

' Add your comments here
sqlConn = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Database & "")

' Add your comments here
sqlDA = New OleDbDataAdapter("select * from tblUserActivity", sqlConn)

' Add your comments here
DS = New dsUserActivity

' Add your comments here
sqlDA.Fill(DS.tblUserActivity)

' Add your comments here
Return DS
End Function

' This function saves the user activity
Public Shared Function SaveUserActivity(ByVal Database As String, ByVal FormAccessed As String)
' Add your comments here
Dim conn As New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Database & "")
conn.Open()
Dim command As OleDbCommand = conn.CreateCommand()
Dim strSQL As String

strSQL = "Insert into tblUserActivity (UserIP, FormAccessed) values ('" & _
GetIP4Address() & "', '" & FormAccessed & "')"

command.CommandType = CommandType.Text
command.CommandText = strSQL
command.ExecuteNonQuery()
conn.Close()
End Function

' This function gets the IP Address
Public Shared Function GetIP4Address() As String
Dim IP4Address As String = String.Empty

For Each IPA As IPAddress In Dns.GetHostAddresses(HttpContext.Current.Request.UserHostAddress)
If IPA.AddressFamily.ToString() = "InterNetwork" Then
IP4Address = IPA.ToString()
Exit For
End If
Next

If IP4Address <> String.Empty Then
Return IP4Address
End If

For Each IPA As IPAddress In Dns.GetHostAddresses(Dns.GetHostName())
If IPA.AddressFamily.ToString() = "InterNetwork" Then
IP4Address = IPA.ToString()
Exit For
End If
Next

Return IP4Address
End Function




if Not Page.IsPostBack Then
' Declares the DataSet
Dim myDataSet As New dsUserActivity

' Fill the dataset with what is returned from the function
myDataSet = clsDataLayer.GetUserActivity(Server.MapPath("PayrollSystem_DB.mdb"))

' Sets the DataGrid to the DataSource based on the table
grdUserActivity.DataSource = myDataSet.Tables("tblUserActivity")

' Binds the DataGrid
grdUserActivity.DataBind()
End If





End Class


Warning 1 Function 'SaveUserActivity' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used. C:\Documents and Settings\Compaq_Owner\My Documents\Visual Studio 2005\WebSites\PayrollSystem\App_Code\clsDataLayer.vb 50 5 C:\...\PayrollSystem\

Error 2 Statement cannot appear outside of a method body. C:\Documents and Settings\Compaq_Owner\My Documents\Visual Studio 2005\WebSites\PayrollSystem\App_Code\clsDataLayer.vb 80 1 C:\...\PayrollSystem\

Error 3 Declaration expected. C:\Documents and Settings\Compaq_Owner\My Documents\Visual Studio 2005\WebSites\PayrollSystem\App_Code\clsDataLayer.vb 85 1 C:\...\PayrollSystem\

Error 4 Declaration expected. C:\Documents and Settings\Compaq_Owner\My Documents\Visual Studio 2005\WebSites\PayrollSystem\App_Code\clsDataLayer.vb 88 1 C:\...\PayrollSystem\

Error 5 Declaration expected. C:\Documents and Settings\Compaq_Owner\My Documents\Visual Studio 2005\WebSites\PayrollSystem\App_Code\clsDataLayer.vb 91 1 C:\...\PayrollSystem\

Error 6 'End If' must be preceded by a matching 'If'. C:\Documents and Settings\Compaq_Owner\My Documents\Visual Studio 2005\WebSites\PayrollSystem\App_Code\clsDataLayer.vb 92 1 C:\...\PayrollSystem\

2 replies

pro-genius Posts 185 Registration date Tuesday November 18, 2008 Status Member Last seen January 29, 2010 68
Mar 27, 2009 at 03:58 AM
give me some time so as i can study the code and come back to you
5
how can i solve zip code error?
0