Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

This is an open thread to general thoughts and ideas about programming and interacting with a database.

 

I have been developing windows applications that rely on a database for the past few years. I am the only developer for the company I work for, so I don't have anyone to bounce ideas off of. I got some experience in college and graduate school, but I don't seem to have the time to just play around with different programming ideas. I seem to always need to be productive. So, I wanted to see how other programmers design and implement applications that communicate with a database.

 

Currently, I don't like to rely on binding any fields to a DataTable. I usually write a SetupFields function that loads the windows form fields with the appropriate information based on the current row in the datatable that the user has 'chosen'. I allow the user to edit the fields, and when they click Save, then I validate all fields manually (make sure monetary fields are formatted correctly, etc.) and the create an UPDATE (or INSERT INTO for a new record) statement and send that to the database. Then I update the datatable locally and continue. I've been wondering about writing classes for each table in the database and having each class be responsible for data retrieval and updates. Is this a good idea? What about validation? It seems like I am always writing validation/updating code to make changes in my database. Is there a better way to do this?

 

I would just like to hear other stories and comments about database programming from other experienced programmers. I program in C#, but I also have some legacy applications that were written in VB6. My applications seem to work, I just want to be a better programmer.

Posted

I was never tasked to do major db development. The small things I had to do were solved with my own object relational mapping. For larger projects I would stick with the pro tools. In java my coworkers would usually use hibernate.

 

Back in the days I didn't even think about a database abstraction layer but I would also hardcode constant values into my programs :D

Debug me...
Posted
This is an open thread to general thoughts and ideas about programming and interacting with a database.

 

I have been developing windows applications that rely on a database for the past few years. I am the only developer for the company I work for, so I don't have anyone to bounce ideas off of. I got some experience in college and graduate school, but I don't seem to have the time to just play around with different programming ideas. I seem to always need to be productive. So, I wanted to see how other programmers design and implement applications that communicate with a database.

 

Currently, I don't like to rely on binding any fields to a DataTable. I usually write a SetupFields function that loads the windows form fields with the appropriate information based on the current row in the datatable that the user has 'chosen'. I allow the user to edit the fields, and when they click Save, then I validate all fields manually (make sure monetary fields are formatted correctly, etc.) and the create an UPDATE (or INSERT INTO for a new record) statement and send that to the database. Then I update the datatable locally and continue. I've been wondering about writing classes for each table in the database and having each class be responsible for data retrieval and updates. Is this a good idea? What about validation? It seems like I am always writing validation/updating code to make changes in my database. Is there a better way to do this?

 

I would just like to hear other stories and comments about database programming from other experienced programmers. I program in C#, but I also have some legacy applications that were written in VB6. My applications seem to work, I just want to be a better programmer.

 

I used to be an independent contractor, but now am doing exactly what you're doing, working as the only developer for a company that does a web-based app dependent on a database

 

I wrote, "The Dynamic Data Dictionary" as a discussion of how to use one Insert and Update statement for all of your inserts and updates. This isn't a 'buy my book' post, that is just a point of reference.

 

I am a great believer in a data dictionary for ease of maintaining your fields and keeping code down. By writing a single statement that uses command parameters, and keeping the all of the field criteria in the datatable table, I cut down my overhead and my error trapping, and this means I write better code and write it faster.

 

Hope that helps

Read the Fovean Chronicles

Because you just can't spend your whole day programming!

Posted
That's an interesting idea. However, I like to do field validation where focus can be set to the field that is not validated and give a reason why. Do you take that into account for your data dictionary design?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...