Et script lagt udenfor Sub_Page_Load
HejJeg ønsker:
Sub Page_Load(sender As Object, e As EventArgs)
.
.
end sub
fjernet. Jeg har beskrevet scriptet nedenfor under Oprindelig script:
Det skal framover laves uden Sub_Page_Load som beskrevet under
Ønsket nyt script:
Kan i hjælpe med at rette det ny script til så det virker
Oprindelig script:
<script language="VB" runat="server" >
Sub Page_Load(sender As Object, e As EventArgs) <----- Skal væk
Dim MyConnection As New OleDbConnection()
MyConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Besog.mdb"
Dim strSQL As String = "INSERT INTO Besogende (REMOTE_HOST,Dato) VALUES('" & request.ServerVariables("REMOTE_HOST") & "','" & now() & "')"
Dim objCommand As New OleDbCommand(strSQL, MyConnection)
MyConnection.Open()
objCommand.ExecuteNonQuery()
MyConnection.Close()
End Sub <----- Skal væk
</script>
Ønsket nyt script:
<script language="VB" runat="server" >
Dim MyConnection As New OleDbConnection()
MyConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Besog.mdb"
Dim strSQL As String = "INSERT INTO Besogende (REMOTE_HOST,Dato) VALUES('" & request.ServerVariables("REMOTE_HOST") & "','" & now() & "')"
Dim objCommand As New OleDbCommand(strSQL, MyConnection)
MyConnection.Open()
objCommand.ExecuteNonQuery()
MyConnection.Close()
</script>