vb.net database

I am using the following code, it is connected to an access database. I am lost on how to now take the connection and tie it to a textbox, then when the use adds data to the textbox having a button to update the access database. I am using a style that I have always been familiar with and would like to continue using:


con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "database.mdb; Jet OLEDB:Database Password="
con.Open()
cmd.Connection =con
cmd.CommandText = "Select * from Table1"
dataadapter.selectcommand = cmd
dataadapter.Fill(dataset1, "Table1")


now what should I do I tried this:
 txtnames.Text = (dataset1.Tables("Table1").Rows(0).Item(dataset1.Tables("Table1").Columns(0)))


and it did put the data inside the textbox and then I just create a button that had an UPDate sql command that just looked at the textboxes and updated records. The problem is that if the field is blank(null) the programs pops up an error, also I do not know if this is the best way to do what I need it to do. So please show some code to get me what I need to complete this project I am working on.

Thanks

hogan9111Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hogan9111Author Commented:
would this be the way to have the data from the database go into certain textboxes


 txtname.DataBindings.Add("Text", dataset1.Tables ("Table1"), "Name")
0
KindaianCommented:
instead of:

 txtnames.Text = (dataset1.Tables("Table1").Rows(0).Item(dataset1.Tables("Table1").Columns(0)))

use:

 txtnames.Text = "" & (dataset1.Tables("Table1").Rows(0).Item(dataset1.Tables("Table1").Columns(0)))

That will avoid the "null" error because concatenation of a string with a null will return the string... (that way you won't use any data bind...)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hogan9111Author Commented:
Is it better to use this method:

 txtnames.Text = "" & (dataset1.Tables("Table1").Rows(0).Item(dataset1.Tables("Table1").Columns(0)))

or this:

txtname.DataBindings.Add("Text", dataset1.Tables ("Table1"), "Name")

also what exactly is the databindings
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Daywalker46410Commented:
As for catching errors, you can either pre-check the textbox for empty values:

If txtnames.Text.Trim = "" Then
    ' Scold the user however you like
Else
    ' Update the dataset.

You can also put the Update code in a Try..Catch..Finally block and create a specific Catch for the DBNull error.
0
hogan9111Author Commented:
Is it better to use this method:

 txtnames.Text = "" & (dataset1.Tables("Table1").Rows(0).Item(dataset1.Tables("Table1").Columns(0)))

or this:

txtname.DataBindings.Add("Text", dataset1.Tables ("Table1"), "Name")

also what exactly is the databindings
0
hogan9111Author Commented:
anyone there
0
KindaianCommented:
Data bind is a way to "link" a controler to a database so that updates to the record are reflected to the database.

It is most usefull for simple, i mean very simple, data insertion/update.

It is a question on where you place the code to retrieve/store the data in the database. I prefer to have a function to get/set the data in a central way and in "my" code, so i can manipulate the data in the forms at my will before storing it in the database.

But, that is my option... there are "style" consideration here... There will be lots of other developers that have diferent views...
0
KindaianCommented:
Thanx for the award ;)

[it was btw my first answer in the site hehehe]
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.