- I have the following tiers set up:
a DB I/O tier for DB calls
a Strongly Typed Dataset tier which contains the datasets. Any project can now access these datasets simply by creating a reference to it. This project has the previous project as a reference.
a Business Tier which has my methods for selecting & updating data. This has the previous two projects set as a reference.
a Presentation Tier which has the previous 3 projects as a reference.
The problem I'm having is that when I try to view the page in the browser, the following error comes back:
"Procedure 'usp_SelectCustomers' expects parameter '@Country', which was not supplied".
My Business Tier has the following two methods in it:
<code>
Public Function SelectCustomers(ByVal strCountry As String) As dstCustomers
Dim dst As New dstCustomers
Try
SQLServerDataAccess.GetSQLData(SqlConnection1, SqlDataAdapter1, dst)
Catch ex As Exception
Throw ex
Finally
SqlDataAdapter1.Dispose()
If SqlConnection1.State = ConnectionState.Open Then
SqlConnection1.Close()
End If
End Try
Return dst
End Function
Public Function UpdateCustomers(ByVal dst As dstCustomers) As Integer
Try
SQLServerDataAccess.ExecuteSQLNonQuery(SqlConnection1, SqlDataAdapter1, dst)
Catch ex As Exception
Throw ex
Finally
SqlDataAdapter1.Dispose()
If SqlConnection1.State = ConnectionState.Open Then
SqlConnection1.Close()
End If
End Try
End Function
</code>
You can see that I have the parameter set up correctly in the Select method.
I have the following HTML in my source view of the presentation page:
<code>
<
asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" CellPadding="4" DataKeyNames="CustomerID" DataSourceID="ObjectDataSource1"
ForeColor="#333333" GridLines="None">
.
.
.
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DataObjectTypeName="StronglyTypedDataSets.dstCustomers"
DeleteMethod="UpdateCustomers" InsertMethod="UpdateCustomers" SelectMethod="SelectCustomers"
TypeName="BusinessLayer.Component1" UpdateMethod="UpdateCustomers">
<SelectParameters>
<asp:ControlParameter ControlID="TextBox1" DefaultValue="USA" Name="strCountry" PropertyName="Text"
Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
</code>
You can see where I have the DefaultValue set up as "USA". I don't know why it's still expecting a parameter when one should be being passed in.
I also am very confused about calling methods in your middle tier (using the ObjectDataSource) and sending them back via a Dataset. When I was using vs.net 2003, I could simply drag a dataset object onto the form designer and refernce a strongly typed dataset in a middle tier project that the presentation tier was referencing. That way, the middle tier methods populate the dataset, pass it back up, then bind it to a datagrid, for instance. The same goes for populating the dataset in the presentation page and sending it down to the middle tier to update the database.
A couple of things:
I would like to know how to do this similiar functionality. There is no Dataset object in the toolbox to drag onto the form. When I try to add the strongly typed dataset of the referenced middle tier object into the app_code folder and compile, I get the following error msg:
"'StronglyTypedDataSets.Settings' is inaccessible due to its protection level" - the assoicated generated code is as follows for this error:
<code>
private void InitConnection() {
this.m_connection = new System.Data.SqlClient.SqlConnection();
this.m_connection.ConnectionString = StronglyTypedDataSets.Settings.Default.NorthwindConnectionString;
}
</code>
I can't seem to access the dataset, because its scope is Private.
I also want to be able to use the Strongly Typed Datasets in my presentation tier which I have reference in my middle tier.
The last thing is how come I don't have to write any code to get the data? When I load the page, it tries right away to load the data. I want manual control of when to call the methods in my middle tier to access and update the data.
Can someone please help me in being able to successfully use the ObjectDataSoruce with strongly typed datasets? I know I'm missing something, but can't figure it out. I tried looking on the web and this forum, but can't find anything to solve the problem.