Saving a searching for Data in an SQL Server?

Soldato
Joined
30 Jul 2004
Posts
10,572
Location
East Sussex, UK
Howzit Guys,

I'm busy building an application that has to hold customer infomation. Now I am using VB 2005 to desgin the and build the program. I have done the GUI on the Form.vb and have added a SQL DataBase, then I made some tables with colums and set all my textBox DataBindging properties to the matching coloums in the database.

Now, what I would like to do is add a Search, Save and Add function. I have placed the Button controls on the form, but, obviously they don't have any code to control that function.

Could anyone tell me what or how to add code to those buttons to achive what I am trying to do?

Any help would be greatly appericated! :)

Robbie.
 
No, I want to add data to the data base, through the application. I also wanted to be able to sea5rch the data base for customers which i have sorted now, but it's just the add function I cant get right. :(
 
From what I can gather you simply want to add records to a database? which is quite simple using sql. I haven't done it in vb.net however so you will need to find a relevant msdn entry to help you.

Been awhile since i've done sql but from memory an insert statement is something like:

"INSERT INTO db.table('col1','col2'...) VALUES('value1','value2'...)"

You can replace the 'value1' with textbox1.text if you want it to be user inputted data. However remember to validate the data before you execute the sql string.
 
I tried the MSDN site, no help, they gave me this code:

me.validate ()

me.YouTableBindingSource.EndEdit () ;

me.YourTableAdapter.update(me.yourDataset.YourTable

How do I validate it then, and do I use the code you provided in a button_click_event?

Thanks a lot for the help, I will try it tonight.

Also, if you know, how do I have the data to the data base then, so when I re open the program it will be still be in the DB.

If I have a lot of text boxes, do I have to enter them all into that code?
 
hmm thing is it appears that you are using some sort of data control to manage the data coming from your database, where as last time I did a DB app I was using VB6 and just raw SQL queries to manage my database. So if i'm honest I don't know how you would do it with the classes yer using.

I would imagine they provide an update method as mentioned by the msdn article, and that if you update through this it will automatically handle updating your database.
 
Back
Top Bottom