Need some help integrating SQL

idealis

New member
Joined
Nov 5, 2007
Messages
3
Programming Experience
1-3
Hi everyone!

My first question on this forum is about a problem that I have trying to combine VB and SQL. I have a database called "project" with a table called "tree" there. This table contains the following columns: "id", "itemname", "description" and "parent". I want to add each "itemname" into a ComboBox upon loading the form, but I can't even seem to be able to successfully create a connection, not to mention I am not getting the SQL sentences right. Can someone help me? :D

I will need a lot of help with my project, but I want to have something to start with...

Cheers!
 
I am completely new to VB.NET, so if you tell me where should I look for the information you need, I will be more than happy to give it to you :D The only info I can see right now is:

Connection String: Data Source=.\SQLEXPRESS;AttachDbFilename=D:\Proyectos\CALC_VBSQL\CALC_VBSQL\sqlProjectTemplate.mdf;Integrated Security=True;User Instance=True
Provider: .NET Framework Data Provider for SQL Server
Type: Microsoft SQL Server
Version: 09.00.1399
 
My first question on this forum is about a problem that I have trying to combine VB and SQL. I have a database called "project" with a table called "tree" there. This table contains the following columns: "id", "itemname", "description" and "parent". I want to add each "itemname" into a ComboBox upon loading the form, but I can't even seem to be able to successfully create a connection, not to mention I am not getting the SQL sentences right. Can someone help me?

As Fremus has suggested, also check out the link for the 2005 walkthroughs in my signature, and read about the "creating a simple data application" (I sound like Cjard now!)

Read through the walkthroughs because there is a great deal of help and information in them.

At a quick answer - in VS2005, you need to make a dataSource to your dataTable. This will create your connection. It will also create a dataSet for you containing the tableAdapters which are related to your DB tables. You can access these from any form within your project.
On your form place the combobox. Set the dataSource to be your Tree tableAdapter, and then set the Display Member to be ItemName and ValueMember to be ItemID
 
Last edited:
Thank you very much for the links, I was trying to find them but I didn't know exactly where to go :).

Now I found a big problem, and maybe this is off-topic but I will give it a try anyway: Each project that users will work on should have four tables associated, say, table1 to table4; but then I don't know how to make each set of tables unique to each project. Were it in Access, I would simply duplicate a "template" and give it a unique filename. But in SQL, how could I manage this? Maybe create tables inside the main database file, each set's tables being prefixed in some way (for example, projectN_table1 to projectN_table4)? Or just create new run-time connections (if it's possible)? By the way, if the second choice is possible, it could help me even more, since I could eventually need different databases for different kinds of projects...

I hope it's not too confusing :confused: :(

Cheers!
 
SQL Express & SQL Server...

if you use SQL express, it means that the database is stored within the project. Therefore if you have the project installed on 10 PCs, each PC will have it's own instance of the database.

If you use MS SQL Server, the database is central, and all users access the same data.
 
SQL Express can also be accessed from remote machines, you just have to enable it and use correct connection string.
 
I will need a lot of help with my project, but I want to have something to start with...

Cheers!

Go to the DW2 link in my signature and read the "Creating a Simple Data Application" section

Initially, if youre new to all this, dont try and modify the advice for your context, download the sample DBs and do it exactly as youre told. THenh when you understand what/how stuff works, try it on your DB
 
Back
Top