• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 241
  • Last Modified:

Finally Crossing Over

I got tired of everyone telling me I was not a real programmer becasue I only used ms access for my projects, so I have undertaken the huge task of learning c#. I have read about 3 books, and am now working on my forth book, "Programming forms with c#".  
Either way, My question is,
I have 2 tables,
Table 1 is of vendors
Table 2 is of vendor products

Table 1 has a foreign key to table 2. When I load up table 1 in the grid, it is showing the actual key. I need it to show the name of the product instead of the key, and allow the user to select a product from a combo box.
0
ppearson3000
Asked:
ppearson3000
1 Solution
 
ppearson3000Author Commented:
I forgot to mention, that the relationship is set up properly in the sql server. When it imports from the db, it shows the relationship but odly enough it shows the products table with the vendor table as a sub table in the server listing.
0
 
Bob LearnedCommented:
1) Access provides some nice functionality so that you don't need to know how things work, they just do

2) With C# you need to understand more about the underlying nature of things

3) You haven't give us enough information to understand what you mean.

4) .NET version?  2002, 2003 or 2005?

5) What server listing?  Server Explorer?

Bob
0
 
ppearson3000Author Commented:
yes.. I am working with .net 2005. It cost me like 500 bucks. and I am talking about server explorer.
I miss access by the way. This was never a problem. I actually did not have to make a database diagram when I used access, I could just link them up in the queries. But apparently I have to have a database diagram with a dfd (which I know how to make, but am just lazy). Either way, I am still trying to get those products to show in the drop down, instead of the product numbers, and then have them save back into the db as the product numbers.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
mrichmonCommented:
>>I got tired of everyone telling me I was not a real programmer becasue I only used ms access for my projects
Are you sure C# is what they were referring to and not a database?

In either case along with learning C# you should consider learning a real database like SQL server.
0
 
bdsmithbackCommented:
In C#, when you do a query on a table like select * from tablename1, it will return all of the information from that table only.  It sounds like you need to do a join to get the information you desire.  Select * from tablename1 join tablename2 on tablename1.foreignkey = tablename2.primarykey.  If you haven't looked into ADO.net yet, that's a great place to start: http://msdn2.microsoft.com/en-us/library/e80y5yhx.aspx.
0
 
ppearson3000Author Commented:
I have an interesting situation in that I have done some pretty advanced stuff with ms access. I worked mostly with sql server 2000 and access data projects. Most of my form changes involved changing the recordsource of a form to a sql statement based on some user input, and then requeryin the form. either way I am on book number 3 on c#, and I figured out how to get the lookup table to work properly. All I had to do was go into the column on the datagrid, and bind it to the product table directly. I made the value equal to the primary key, and I made the shown column be the name of the product.
the only remaining portion of this question that is unanswered is, now I am getting a data exception. I know that I need to put it in a try/catch construct, but I can't seem to find the code that I surround for the datagrid. Would it be in the initialize component()??
0
 
bdsmithbackCommented:
You can do a general try - catch block and catch all exceptions.  IE:

try
{
    .... code for database access
}
catch(Exception ex)
{
     MessageBox.Show(ee.ToString());
}

This will catch any exception in the try block and display the error in a Message Box.
0
 
bdsmithbackCommented:
Thanks ppearson3000
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now