Results 1 to 8 of 8

Thread: [RESOLVED] REAL NEWBIE - Help Please!

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2008
    Posts
    13

    Angry [RESOLVED] REAL NEWBIE - Help Please!

    Okay I have written a few programs in VB (5 and 6) but no nothing about .NET or database programming. I am trying to write a program for a friend of mine who works for a trucking company and well I am at a complete lost how to read/write to/from a database and format database output for printing.

    Below is a screenshot of the application I am writing. The database is created and there are three tables (one for each division of the company). The fields are the same for ALL TABLES all though some won't be used in certain tables. I just made them all the same for simplicity sake. My field names are all named the same as the columns in the tables, again for simplicity's sake. I have the database connection setup in the program. My problems are:

    1.) How do I get the data in all the fields written to the appropriate table/column in the database when the Submit Load Info button is clicked.
    2.) How do I get the correct data out of the database, formatted for print using a template that gets populated automatically when the button is pressed then printed.

    Last edited by venuspcs; Oct 23rd, 2008 at 01:46 PM.

  2. #2
    Addicted Member
    Join Date
    Jun 2006
    Location
    New Orleans, LA
    Posts
    161

    Re: REAL NEWBIE - Help Please!

    Try http://www.vbforums.com/showthread.php?t=469872

    There is a user on these forums by the name of jmcilhinney. He is a genius when it comes to .NET database information. You would do well to find one of his post and check out some of the links in his signature. The above link will probably be the most helpful in your situation.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: REAL NEWBIE - Help Please!

    First up, you neglected to attach your screen shot.

    Secondly, your database design is flawed. If all three of your tables are the same then they should all be the one table. You should add a Division table and then add a DivisionID column to the other table, thus relating each record to a specific division.

    At the top of this forum is a sticky thread that includes numerous links, including one to the same ADO.NET code examples as the Data Access link in my signature.

    Printing in .NET is done using a PrintDocument object. You call its Print method and handle its PrintPage event. In the PrintPage event handler you use GDI+ to draw the output for a printed page. GDI+ can draw text, lines, curves, shapes, etc. so you can have as fancy output as you want. If you're going to go this way then I'd suggest reading the documentation for the PrintDocument class for starters.

    If you want to display your data in a grid and then just print that then all the heavy lifting has been done for you. Merrion has posted a class in the VB.NET CodeBank forum that will print the contents of a DataGridView, hiding the complexity of the PrintDocument.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: REAL NEWBIE - Help Please!

    Quote Originally Posted by Minolwen
    Try http://www.vbforums.com/showthread.php?t=469872

    There is a user on these forums by the name of jmcilhinney. He is a genius when it comes to .NET database information. You would do well to find one of his post and check out some of the links in his signature. The above link will probably be the most helpful in your situation.
    I was typing my response when you posted. There's another vote for that same link, and thanks for the complement.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2008
    Posts
    13

    Re: REAL NEWBIE - Help Please!

    I posted the screenshot but for some reason it refuses to work. I right clicked on the icon and Copy Shortcut and it works. Don't know why it won't show up. As far as why I am using three different tables in the same database, I am doing that to make it easier to generate daily, weekly, monthly, quarterly and yearly reports for each division/driver/truck.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: REAL NEWBIE - Help Please!

    Quote Originally Posted by venuspcs
    I posted the screenshot but for some reason it refuses to work. I right clicked on the icon and Copy Shortcut and it works. Don't know why it won't show up.
    I don't really know what you're saying you did but there's only one way to attach images to a post, and that's using the Manage Attachments button in the advanced editor.
    Quote Originally Posted by venuspcs
    As far as why I am using three different tables in the same database, I am doing that to make it easier to generate daily, weekly, monthly, quarterly and yearly reports for each division/driver/truck.
    You are misguided. Like I said, in the combined table each record would have a DivisionID so there's no problem getting data that relates to a specific division. You simply specify the DivisionID for that division in your WHERE clause. The same goes for filtering by truck or driver. You would have a table for Trucks and a table for Drivers and the IDs from those tables would be used to identify records related to those trucks or drivers. You can then filter your queries by specifying a TruckID or DriverID or both in the WHERE clause.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7
    Hyperactive Member
    Join Date
    Jan 2008
    Location
    Merseyside
    Posts
    456

    Re: REAL NEWBIE - Help Please!

    venus,

    if you can post 2-3 lines of example data from each of your 3 tables, we might be able to demontrate better how to combine the tables, using your example data.

  8. #8

    Thread Starter
    New Member
    Join Date
    Oct 2008
    Posts
    13

    Re: REAL NEWBIE - Help Please!

    A couple guys over in the codebank got me fixed up on that problem. I can post the date to the datebase to the appropriate table with no problem now.

    I have however posted a new problem here: http://www.vbforums.com/showthread.p...00#post3363300 if anyone can help me with it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width