R
Rayne
I have a combobox that is bound to a datasource. It lists the users in
the system and I want it to automatically select the current logged on
user, so that the screen loads that user's information by default when
the app loads.
I have a stored procedure in SQL Server that returns the integer value
of the userid, but I'm having trouble setting that to be the selected
record in the combobox.
In the stored procedure I have:
declare @EID int
select @EID = coalesce(ID, 0) from Employees where Name = @ename
return @EID
It successfully returns the UserID
In VB.net I added that stored procedure as a single value query to my
table adapter for the Employee table. Then in the code I have:
cboEmployees.SelectedValue =
me.EmployeesTableAdapter.get_EmployeeIDbyName(fullname)
fullname is assigned the current user's full name when the app loads.
At first I was getting an exception that the nullable object must have
a value. So I edited the return value on the query in the table adapter
to AllowDBNull = False since the stored procedure will return 0 if the
logged in user isn't yet in the DB anyway.
When I preview data from the dataset designer, it returns the correct
value, but when the code runs, it doesn't select the matching record.
I also tried assigning the return value to a integer variable, then put
a breakpoint to check the value...it didn't return the right value. So
somehow when the table adapter calls the query something isn't right.
Can anyone please help with this? It's critical that the app load the
current user info by default.
Thanks!
Rayne
the system and I want it to automatically select the current logged on
user, so that the screen loads that user's information by default when
the app loads.
I have a stored procedure in SQL Server that returns the integer value
of the userid, but I'm having trouble setting that to be the selected
record in the combobox.
In the stored procedure I have:
declare @EID int
select @EID = coalesce(ID, 0) from Employees where Name = @ename
return @EID
It successfully returns the UserID
In VB.net I added that stored procedure as a single value query to my
table adapter for the Employee table. Then in the code I have:
cboEmployees.SelectedValue =
me.EmployeesTableAdapter.get_EmployeeIDbyName(fullname)
fullname is assigned the current user's full name when the app loads.
At first I was getting an exception that the nullable object must have
a value. So I edited the return value on the query in the table adapter
to AllowDBNull = False since the stored procedure will return 0 if the
logged in user isn't yet in the DB anyway.
When I preview data from the dataset designer, it returns the correct
value, but when the code runs, it doesn't select the matching record.
I also tried assigning the return value to a integer variable, then put
a breakpoint to check the value...it didn't return the right value. So
somehow when the table adapter calls the query something isn't right.
Can anyone please help with this? It's critical that the app load the
current user info by default.
Thanks!
Rayne