Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / November 2004

Tip: Looking for answers? Try searching our database.

Parameter on Stored Procedure

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gis - 12 Nov 2004 11:56 GMT
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?
thx.
Gis - 12 Nov 2004 12:14 GMT
I'm VERY VERY SORRY!!! I found the mistake... I was calling another
dataadapter when adding EmployeeID parameter..
thx!

> Hi,
> I'm using a data adapter daReadAdmin which is delcared like this:
[quoted text clipped - 32 lines]
> should I add the GUID Parameter?
> thx.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.