Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extreme Newbie Question - working with SQL 2005 with VB.NET

Status
Not open for further replies.

fergmj

Programmer
Feb 21, 2001
276
US
I have a very simple database called CABLE.
it has three tables (CLIENT, SCHEDULE, STAFF)

I want to write an application that will allow me to ADD, UPDATE and DELETE rows in these tables. I am well versed in SQL so no problem there but I'm not sure how to get started in VS2005 (VB.NET) to use the data in my data base.

I have tried several examples from websites and I am able to bind data and I have a form with the toolbar that drops on so you can go thru each row of data but that really isn't practical to what I want. I want a user to be able to

SELECT * from CLIENT where clientid = 3 and the result returned would populate the items on my form that make up the data returned from the result string.

Can someone help me? Hopefully I am clear..I think the more I think about this the more confused I am in my own mind.

fergmj
 
There is probably a FAQ for this, but here is the 1 min explanation:

You will need stored procs, for the Select, Insert, Update, Delete (please tell me you aren't using access)

You will need to create an SQLConnection object (found in System.SqlClient)
From there you will need to create an SQLCommand (SQLClient)
You will take your SQLCommand Object and ".AddWithValue("@ClientID",intClientID)
Then you will call something on the sql command object that will return a data table. I cannot remember what it is called, cause i made a generic wrapper for getting data into an sql table. (Which i will post once i get to work)
From there, you now have a datatable, and you can spool it and do what you want with it.

You will want to wrap that logic in a Try Catch, and watch out for SQLTimeout errors, in case someone else is locking the database.

-Sometimes the answer to your question is the hack that works
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top