silverferret
New Member
Hi<BR>I am getting the following error when I run aspx file.<BR>I am connecting to remote server from a local machine and accessing SQL SERVER 2000 database.<BR>The path I am using to connect to database on server is as follows....<BR><BR>MyConnection = New SqlConnection ("data source="...";initial catalog="...";user id="....";workstation id="...."")<BR><BR>I am using data grid control to display table contents on a form.<BR><BR>Can some one help me with this...<BR><BR>Thanks,<BR>Naveen.<BR><BR><BR>You should probably post the rest of the code so we can see it, but it sounds like you are not declaring your dataset, ie:<BR><BR>Dim objDS As yourDataSetClassI am running Dataform wizard from visual studio.NET and it generated code and so I am not sure if I have to explicitly declare that..<BR>So that makes me think that I have the SQL connection configured wrong because, none of the applications involving databases are working.Well, you may have connection configuration issues, but I can tell you from the error that you have not declared objDS, yet you are trying to reference it. Try posting some code and we'll see if we can try to point you in the right direction.This is the line where I am getting error in the aspx file.<BR>Its not recognizing objDS in the data source and this is wizard generated code.<BR><BR><BR><asp
ataGrid runat="server" DataKeyField="OrderID" PageSize="5" AutoGenerateColumns="False" Height="50px" Width="100%" DataMember="Ordertable" ID="masterDataGrid" CellPadding="2" DataSource="<%objDS%>"><BR><Columns><BR> <asp:BoundColumn DataField="OrderID" HeaderText="OrderID"></asp:BoundColumn><BR> <asp:BoundColumn DataField="MemberNumber" HeaderText="MemberNumber"></asp:BoundColumn><BR>...................and so on............<BR><BR>Let me know if you need to see the code behind module.<BR>I appreciate your help.<BR>Naveen.<BR><BR>Yep need the code behind.This is the entire code behind below other than web form designer code...<BR><BR>Public Class DataWebForm4<BR> Inherits System.Web.UI.Page<BR> Protected WithEvents OleDbSelectCommand1 As System.Data.OleDb.OleDbCommand<BR> Protected WithEvents OleDbInsertCommand1 As System.Data.OleDb.OleDbCommand<BR> Protected WithEvents OleDbUpdateCommand1 As System.Data.OleDb.OleDbCommand<BR> Protected WithEvents OleDbDeleteCommand1 As System.Data.OleDb.OleDbCommand<BR> Protected WithEvents objDS As samples.DS<BR> Protected WithEvents OleDbConnection1 As System.Data.OleDb.OleDbConnection<BR> Protected WithEvents OleDbDataAdapter1 As System.Data.OleDb.OleDbDataAdapter<BR> Protected WithEvents buttonLoad As System.Web.UI.WebControls.Button<BR> Protected WithEvents masterDataGrid As System.Web.UI.WebControls.DataGrid<BR><BR><BR><BR> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<BR> 'Put user code to initialize the page here<BR> End Sub<BR><BR> Private Sub buttonLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttonLoad.Click<BR> Try<BR> Me.LoadDataSet()<BR> Me.masterDataGrid.SelectedIndex = -1<BR> Me.masterDataGrid.DataBind()<BR> Catch eLoad As System.Exception<BR> Me.Response.Write(eLoad.Message)<BR> End Try<BR><BR> End Sub<BR> Public Sub LoadDataSet()<BR> 'Create a new dataset to hold the records returned from the call to FillDataSet.<BR> 'A temporary dataset is used because filling the existing dataset would<BR> 'require the databindings to be rebound.<BR> Dim objDataSetTemp As samples.DS<BR> objDataSetTemp = New samples.DS()<BR> Try<BR> 'Attempt to fill the temporary dataset.<BR> Me.FillDataSet(objDataSetTemp)<BR> Catch eFillDataSet As System.Exception<BR> 'Add your error handling code here.<BR> Throw eFillDataSet<BR> End Try<BR> Try<BR> 'Empty the old records from the dataset.<BR> objDS.Clear()<BR> 'Merge the records into the main dataset.<BR> objDS.Merge(objDataSetTemp)<BR> Catch eLoadMerge As System.Exception<BR> 'Add your error handling code here.<BR> Throw eLoadMerge<BR> End Try<BR><BR> End Sub<BR> Public Sub FillDataSet(ByVal dataSet As samples.DS)<BR> 'Turn off constraint checking before the dataset is filled.<BR> 'This allows the adapters to fill the dataset without concern<BR> 'for dependencies between the tables.<BR> dataSet.EnforceConstraints = False<BR> Try<BR> 'Open the connection.<BR> Me.OleDbConnection1.Open()<BR> 'Attempt to fill the dataset through the OleDbDataAdapter1.<BR> Me.OleDbDataAdapter1.Fill(dataSet)<BR> Catch fillException As System.Exception<BR> 'Add your error handling code here.<BR> Throw fillException<BR> Finally<BR> 'Turn constraint checking back on.<BR> dataSet.EnforceConstraints = True<BR> 'Close the connection whether or not the exception was thrown.<BR> Me.OleDbConnection1.Close()<BR> End Try<BR><BR> End Sub<BR><BR> Private Sub masterDataGrid_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles masterDataGrid.SelectedIndexChanged<BR><BR> End Sub<BR>End Class<BR>
