Groups | Blog | Home
all groups > dotnet windows forms databinding > november 2004 >

dotnet windows forms databinding : Parameter on Stored Procedure


Gis
11/12/2004 3:56:01 AM
Hi,
I'm using a data adapter daReadAdmin which is delcared like this:

SqlDataAdapter daReadAdmin = new SqlDataAdapter("p_ReadAdmin",
strConnection);

Where p_ReadAdmin is a parametrized Stored procedure in SQL Server then the
following code states:

daReadAdmin.SelectCommand.CommandText = "p_ReadAdmin";
daReadAdmin.SelectCommand.CommandType = CommandType.StoredProcedure;

After this i set the parameters:

daTimeRecording.SelectCommand.Parameters.Add("@EmployeeID",
SqlDbType.UniqueIdentifier,0,cboName.SelectedValue.ToString());
daReadAdmin.SelectCommand.Parameters.Add("@TRDate", dtpDate.Value);

Then the DataSet must be filled:
daReadAdmin.Fill(dsReadAdmin, "p_ReadAdmin");

Then use a DataView:
dvdgTimeRecording = new DataView(dsReadAdmin.Tables["p_ReadAdmin"]);
dgTimeRecording.DataSource = dvdgTimeRecording;

The Result..: "An unhandled exception of type
'System.Data.SqlClient.SqlException' occurred in system.data.dll Additional
information: System error."
the exception shows on the line "daReadAdmin.Fill(dsReadAdmin,
"p_ReadAdmin");

I think the problem is on passing parameter for @EmployeeID which should be
given by cboName.SelectedValue. EmployeeID is a GUID. If I modify the sp on
SQL to recieve only @TRDate as parameter then everything works fine. How
should I add the GUID Parameter?
Gis
11/12/2004 4:14:02 AM
I'm VERY VERY SORRY!!! I found the mistake... I was calling another
dataadapter when adding EmployeeID parameter..
thx!

[quoted text, click to view]
AddThis Social Bookmark Button