Hi Everyone,
Sorry if I wasn't too clear with my original post. Anyway here's the
code that works on my windows server 2003 machine but not on XP.
I strongly believe that the problem lies somewhere with IIS.
To the code:
The Webform contains:
- two asp linkbutton controls (btnNext and btnPrevious) for navigating
the datagrid
- a datagrid (datagrid1)
- two asp labels (lblStones and lblCarats) for displaying data from the
database
The datasource for the datagrid is a stored procedure (access query).
Here's the sql:
SELECT TOP 10 qryExportDetails.RECEIPTNUM, qryExportDetails.RECEIPTDATE,
qryExportDetails.STONES, qryExportDetails.CARATS,
qryExportDetails.ROYALTIES
FROM qryExportDetails
WHERE (((qryExportDetails.RECEIPTNUM)>[@receiptnum]) AND
((qryExportDetails.exportID)=40))
ORDER BY qryExportDetails.RECEIPTNUM;
Imports System
Imports System.Data
Imports System.Data.OleDb
Public Class WebForm1
Inherits System.Web.UI.Page
Private CurrentPage As Integer
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
Protected WithEvents btnPrevious As
System.Web.UI.WebControls.LinkButton
Protected WithEvents btnNext As System.Web.UI.WebControls.LinkButton
Private connString As String =
"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=D:\OFFICE_DATA\SAMI\2005\exports 2005\ems 05 may 2005.mdb"
And the code for the WebForm:
Protected WithEvents lblCarats As System.Web.UI.WebControls.Label
Protected WithEvents lblStones As System.Web.UI.WebControls.Label
Private objConn As New OleDbConnection(connString)
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
Dim objCmdNext As New OleDbCommand("spNextExportsDetails",
objConn)
Dim objParam As New OleDbParameter("@receiptnum",
OleDbType.BSTR)
objCmdNext.CommandType = CommandType.StoredProcedure
objParam.Value = ""
objCmdNext.Parameters.Add(objParam)
Try
FillGridODB(objCmdNext)
Dim strSQLExport As String = "select WeightCts, Stones
from tblExports where exportID = 40"
Dim objCmdExport As New OleDb.OleDbCommand(strSQLExport,
objConn)
objCmdExport.CommandType = CommandType.Text
objConn.Open()
Dim drExport As OleDb.OleDbDataReader =
objCmdExport.ExecuteReader
While drExport.Read
lblCarats.Text = drExport.GetValue(0)
lblstones.Text = drExport.GetValue(1)
End While
drExport.Close()
objConn.Close()
Catch ee As Exception
Throw ee
End Try
End If
End Sub
Private Sub FillGridODB(ByVal currentODBCommand As
OleDb.OleDbCommand)
Dim dr As OleDb.OleDbDataReader
objConn.Open()
dr = currentODBCommand.ExecuteReader()
DataGrid1.DataSource = dr
DataGrid1.DataBind()
dr.Close()
objConn.Close()
ViewState("CurrentPage") = CurrentPage
viewstate(CurrentPage.ToString) =
DataGrid1.Items(0).Cells(0).Text
If DataGrid1.Items.Count < DataGrid1.PageSize Then
btnNext.Enabled = False
End If
End Sub
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNext.Click
CurrentPage = CType(viewstate("CurrentPage"), Integer)
CurrentPage += 1
Dim objCmdNext As New OleDbCommand("spNextExportsDetails",
objConn)
Dim objParam As New OleDbParameter("@receiptnum",
OleDbType.BSTR)
objCmdNext.CommandType = CommandType.StoredProcedure
Dim lastid As String = DataGrid1.Items(9).Cells(0).Text
objParam.Value = lastid
objCmdNext.Parameters.Add(objParam)
FillGridODB(objCmdNext)
End Sub
End Class