PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Data Access Problem
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Data Access Problem
![]() |
Data Access Problem |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi all,
I hope someone can help with this relatively simple problem. I am building a timesheet application using ASP.NET C# with Visual Studio 2003.As it is only a protoype application, my database has been made in MSDE. As part of my application, I have a 'Resources' table, which holds employee information. I have the fields FirstName and LastName which are entered in my data capture form which works fine. The problem however, is that on other forms, for example, I wish to be able to select employees from a drop-down list which shows both their first and last names. At present my drop-down lists can only showHow should I go about this? Can I create a view or something to achieve this? Or could I insert a 'FullName'column into my 'Resources' table, which is set by default to take the first and last names of each new resource and concatanate it into one string? I worked on an application previously, which seemed to do something similar, although I don't know how. What I did try originally was to show the resource information on the form as a DataGrid, but was unable to successfully pass the SelectedItem when my 'submit' button was pressed. Any thoughts, suggestions would be much appreciated! Thanks again Al |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Al,
One option would be to create a FullName from FirstName and LastName when selecting the data: Select FirstName + ' ' + LastName As FullName ... Kerry Moorman "thebison" wrote: > Hi all, > > I hope someone can help with this relatively simple problem. > I am building a timesheet application using ASP.NET C# with Visual > Studio 2003.As it is only a protoype application, my database has been > made in MSDE. > > As part of my application, I have a 'Resources' table, which holds > employee information. I have the fields FirstName and LastName which > are entered in my data capture form which works fine. The problem > however, is that on other forms, for example, I wish to be able to > select employees from a drop-down list which shows both their first and > last names. At present my drop-down lists can only showHow should I go > about this? Can I create a view or something to achieve this? Or could > I insert a 'FullName'column into my 'Resources' table, which is set by > default to take the first and last names of each new resource and > concatanate it into one string? I worked on an application previously, > which seemed to do something similar, although I don't know how. > > What I did try originally was to show the resource information on the > form as a DataGrid, but was unable to successfully pass the > SelectedItem when my 'submit' button was pressed. > > Any thoughts, suggestions would be much appreciated! > > Thanks again > > Al > > |
|
|
|
#3 |
|
Guest
Posts: n/a
|
TheBison,
You can do it as Kerry shows or with adding a column with an expression to the datatable. The expression is than the same as Kerry shows you. (FirstName + " " + LastName) I hope this helps, Cor "thebison" <alex.sinclair3@btinternet.com> schreef in bericht news:1144248070.930073.181910@u72g2000cwu.googlegroups.com... > Hi all, > > I hope someone can help with this relatively simple problem. > I am building a timesheet application using ASP.NET C# with Visual > Studio 2003.As it is only a protoype application, my database has been > made in MSDE. > > As part of my application, I have a 'Resources' table, which holds > employee information. I have the fields FirstName and LastName which > are entered in my data capture form which works fine. The problem > however, is that on other forms, for example, I wish to be able to > select employees from a drop-down list which shows both their first and > last names. At present my drop-down lists can only showHow should I go > about this? Can I create a view or something to achieve this? Or could > I insert a 'FullName'column into my 'Resources' table, which is set by > default to take the first and last names of each new resource and > concatanate it into one string? I worked on an application previously, > which seemed to do something similar, although I don't know how. > > What I did try originally was to show the resource information on the > form as a DataGrid, but was unable to successfully pass the > SelectedItem when my 'submit' button was pressed. > > Any thoughts, suggestions would be much appreciated! > > Thanks again > > Al > |
|
|
|
#4 |
|
Guest
Posts: n/a
|
1) Create a brand new windows project.
2) Connect to the Northwind database. 3) Drag the "Employee" table onto the designer surface. This will create both a sqlConnection and sqlDataAdapter object. 4) Select the sqlDataAdapter. From this, generate a dataset. 5) Select the dataset object. View the schema. 6) Add an element to the bottom. Name it "FullName". In the properties window, set the Expression to: LastName + ', ' + FirstName 7) Drag a datagrid onto the design surface. Set the DataSource and DataMember properties to the dataset. Set the dock to full. 8) In the form load event, add the following code: sqlDataAdapter1.Fill(dsEmployee.Employee). 9) Run the app. Look at the column FullName Microsoft's ADO technology is pretty impressive. "thebison" <alex.sinclair3@btinternet.com> wrote in message news:1144248070.930073.181910@u72g2000cwu.googlegroups.com... > Hi all, > > I hope someone can help with this relatively simple problem. > I am building a timesheet application using ASP.NET C# with Visual > Studio 2003.As it is only a protoype application, my database has been > made in MSDE. > > As part of my application, I have a 'Resources' table, which holds > employee information. I have the fields FirstName and LastName which > are entered in my data capture form which works fine. The problem > however, is that on other forms, for example, I wish to be able to > select employees from a drop-down list which shows both their first and > last names. At present my drop-down lists can only showHow should I go > about this? Can I create a view or something to achieve this? Or could > I insert a 'FullName'column into my 'Resources' table, which is set by > default to take the first and last names of each new resource and > concatanate it into one string? I worked on an application previously, > which seemed to do something similar, although I don't know how. > > What I did try originally was to show the resource information on the > form as a DataGrid, but was unable to successfully pass the > SelectedItem when my 'submit' button was pressed. > > Any thoughts, suggestions would be much appreciated! > > Thanks again > > Al > |
|
|
|
#5 |
|
Guest
Posts: n/a
|
Hi everyone!
Thanks, that is exactly what I wanted. My drop-down list now shows the FullName and it looks great! While I have your attention....perhaps any of you could assist with another issue I am having on the same form. The basic point of this form is to assign a Resource (Employee) onto a Task, which has previously been assigned to a Project. The way I have laid the form out is that you can select Projects, Tasks, and Employees all from drop-down lists. The user can then add some dates, and click submit to send it to the database. My problem is that I want the Task drop-down list to automatically repopulate with the correct tasks when the user selects a Project from the Project drop-down. What I mean by this is that if for example the user selects "Redistribution Project" from the list, then only tasks from that Project will be available in the Tasks drop-down. I believe I will have to do something with my page_load, specifically the IsPostBack part...but I am not sure exactly. My code is currently: if(!IsPostBack) { this.sqlDataAdapter1.Fill(this.dsProjectName1); ddProjectName.DataBind(); this.sqlDataAdapter3.Fill(this.dsTaskName1); ddTaskName.DataBind(); this.sqlDataAdapter4.Fill(this.dsResourceFullName1); ddResName.DataBind(); sqlConnection1.Close(); } Any help greatly appreciated! Thanks Al |
|
|
|
#6 |
|
Guest
Posts: n/a
|
Hi,
Thanks, I have this working now! :-) I now have another question, I've searched all over the web for the answer, but can't quite work it out. I am filling a list-box with 'Start Date' and 'Finish Date' from a table, and have concatanated these into a new field, 'Full Date'. However when I DataBind the list-box it shows the format as '01/10/06 12:00:00 - 07/10/06 12:00:00'. I do not want the times to show. I know how to format one column, using the DataTextFormatString property, setting it to {0:d} , but I can't work out what it will need to be for my 'Full Date' field. The actual data expression for 'Full Date' is StartDate + '-' + FinishDate And I wish it to show in the ListBox as '01/10/06 - 07/10/06'. Anyone have any ideas on what I should put into DataTextFormatString to achieve this, so that the times are not included? Many Thanks! Al |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

