Eduardo Lorenzo
03-02-2007, 01:16 AM
Hi everyone. Am really new to this SQLDatasourceObject so please bear with my caveman question.
Right now I have this code in the DAL
Public Function GetDataTable(ByVal CommandText As String, ByRef Target As SqlDataSource) As Boolean
Try
thisDatasource.SelectCommand = CommandText
Target = thisDatasource
GetDataTable = True
strErrorMsg = ""
Catch ex As Exception
GetDataTable = False
strErrorMsg = ex.Message
End Try
End Function
the connection string and commandtype are declared as:
Sub New(ByVal ConnectionString As String, ByVal CmdType As SqlDataSourceCommandType)
thisDatasource = New SqlDataSource
thisDatasource.ConnectionString = ConnectionString
thisDatasource.SelectCommandType = CmdType
End Sub
and adding a Select Parameter is like so:
Public Sub addParameter(ByVal paramname As String, ByVal paramval As Object)
thisDatasource.SelectParameters.Add(paramname, paramval)
End Sub
all these functions are in a DAL class called like this:
Public Function getProjectStaff(ByRef target As SqlDataSource, ByVal projectID As String) As Boolean
Dim myhelp As New sqlserverhelper(connstr, SqlDataSourceCommandType.StoredProcedure)
myhelp.addParameter("@projectID", projectID)
If myhelp.GetDataTable("staffPerProject", target) Then
Return True
Else
errormessage = myhelp.ErrorMessage
Return False
End If
myhelp = Nothing
End Function
by the BLL.
The error is triggered here in the Presentation Layer (The page's code behind)
Private Sub loadgrid()
Dim mybll As New PM_BLL
Dim mySource As New SqlDataSource
If mybll.getProjectStaff(mySource, Request.QueryString("ProjectID")) Then
Me.GridView1.DataSource = mySource
Me.GridView1.DataBind() '<---- error is here
End If
End Sub
the code is still pretty much straighforward as I am still just starting this thing.
The error says that the Stored Procedure staffPerProject was expecting the parameter @ProjectID which was not supplied???
BUT!!!! in the GridView1.DataSource = mySource line, mySource.SelectParameters.Count = 1:confused:
All help shall be greatly appreciated.
TIA.
Right now I have this code in the DAL
Public Function GetDataTable(ByVal CommandText As String, ByRef Target As SqlDataSource) As Boolean
Try
thisDatasource.SelectCommand = CommandText
Target = thisDatasource
GetDataTable = True
strErrorMsg = ""
Catch ex As Exception
GetDataTable = False
strErrorMsg = ex.Message
End Try
End Function
the connection string and commandtype are declared as:
Sub New(ByVal ConnectionString As String, ByVal CmdType As SqlDataSourceCommandType)
thisDatasource = New SqlDataSource
thisDatasource.ConnectionString = ConnectionString
thisDatasource.SelectCommandType = CmdType
End Sub
and adding a Select Parameter is like so:
Public Sub addParameter(ByVal paramname As String, ByVal paramval As Object)
thisDatasource.SelectParameters.Add(paramname, paramval)
End Sub
all these functions are in a DAL class called like this:
Public Function getProjectStaff(ByRef target As SqlDataSource, ByVal projectID As String) As Boolean
Dim myhelp As New sqlserverhelper(connstr, SqlDataSourceCommandType.StoredProcedure)
myhelp.addParameter("@projectID", projectID)
If myhelp.GetDataTable("staffPerProject", target) Then
Return True
Else
errormessage = myhelp.ErrorMessage
Return False
End If
myhelp = Nothing
End Function
by the BLL.
The error is triggered here in the Presentation Layer (The page's code behind)
Private Sub loadgrid()
Dim mybll As New PM_BLL
Dim mySource As New SqlDataSource
If mybll.getProjectStaff(mySource, Request.QueryString("ProjectID")) Then
Me.GridView1.DataSource = mySource
Me.GridView1.DataBind() '<---- error is here
End If
End Sub
the code is still pretty much straighforward as I am still just starting this thing.
The error says that the Stored Procedure staffPerProject was expecting the parameter @ProjectID which was not supplied???
BUT!!!! in the GridView1.DataSource = mySource line, mySource.SelectParameters.Count = 1:confused:
All help shall be greatly appreciated.
TIA.