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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datasets?? 2

Status
Not open for further replies.
Apr 12, 2004
98
US
I have created an application that uses a sql connection to retrieve, edit, change data. The application worked fine when I had my data adapter, connection and dataset on just one form to fill a grid. Now I have created two more sets of connections, adapter and datasets but my grids don't fill on execution. Nor can I preview the data in the dataset any longer. If I take out the additional connection, adapters and datasets it works????

I am using sql server with 3 different tables of data. I have created an inner join with two tables on two different forms?

My questions is first of all what am I doing wrong? I did have it working at one point.

Do I need a connection, data adapter and dataset on all three forms within the app???

I also have the following code on form load:
da_profiles.Fill(ds_profiles)

 
Okay, I figured it out. I had an inner join but no data was showing up because I didn't have the same records in both tables. Why can't I now select records from both tables??? I can insert, update without the join but once I join I can't do any of these things... I think it's because I need to update the primary key in both tables???

Does anyone know why I can't select records from more than one table at a time
 
lizzie,
Are you using stored Procedures? Are you using the CommandBuilder in .NET? if you are using the command builder in vb.net you will not be able to use joins with the commandbuilder.

If your not using stored procedures i can get you started.

Sincerely,
Michael
 
Thanks for responding. I have gotten to a point where I can join without error and update, add and delete from my vb app to the sql table. However it does not update the "joined" table as I am still unable to select any records from the joined table.

I am pretty new to both vb and sql so I am not currently using command builder or stored procedures.

All input is truly appreciated!
 
lizzie,
So your just using a variable for your SQL ? It would seems to me that you should look at how to write SQL. Well maybe you could post some code now so i can see what your working on. I would look at and check up on some SQL Union queries. Also you only need one connection, i'm not really sure if you are creating more than one dataset, that may be a problem as well. Unless you show me some code this is about all i can tell you for now.

Sincerely,
Michael Fritts
 
MFritts -

Thanks for your posts. I've been pulled away from this project for a while.

I did manage to get around the joins. I put all data in one table.

However, now I want to be able to click on a row in my grid and have it bring up a form that contains the data from the row I've clicked on. The form comes up but contains the data from the first row in the grid and not the selected row...
 
Hi,
I realise you've not got around the join in the tables, but here's what I've recently used for the same thing(it was a pain trying to find this out!) I created a seperate adapter for each table and used a dataset to create a relation between each table. This now updates/inserts and deletes on all tables in the join.

As for the datagrid problem - can you show the code you are using to call the form?
 
Thanks NickyJay. I can't use the resolution in this project because now I'm on a time crunch due to being pulled away for so long. I will however try it on the next.

Here's my code. Still haven't gotten my for to fill in based on the row I've selected.

Private Sub DataGrid1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.DoubleClick
Dim pt As Point = Cursor.Position
Dim hti As DataGrid.HitTestInfo = DataGrid1.HitTest(pt.X, pt.Y)
Me.Hide()
Dim bm As BindingManagerBase = DataGrid1.BindingContext(DataGrid1.DataSource)
Dim dr As DataRow = CType(bm.Current, DataRowView).Row
Dim frmForm4 As New frmProducer_profile
frmForm4.Show()
End Sub
 
Okay MFritts -

I have to back track. I do need the join so I went back and created my stored procedures. Can you please direct me on how to use them??

Thanks,
Lizzie
 
What exactly would you like to know about stored Procedures? how to create them? access them in your code? i'm just not sure what you want me to tell you, but i'll more than glad to help.

sincerely,
Michael
 
MFritts -

Thanks for your help once again. This is my first "programming" project. No programmers in the company I work for and a deadline to meet so I rely on this site sometimes a little too much.

I created my stored procedures and used command builder in vb.net. However, my stored procedures aren't working. Now I don't get any data. In my grid or forms. Still haven't figured out how to populate a form???

One step back and I'm already sweating trying to figure out where to go with the rest of the project.
 
Okay, I've created a form that relies on two data adapters (one for each sql table) that points to a sql database. I've created a dataset that points to both data adapter tables. Now does anyone know how I can update my tables with the information that I've entered into the textboxes on my form?? I've tried a few different approaches yet none have worked with a form...
 
dataadapter.update(datasetname)

but first you need to do a bindingcontext(datasetname).endcurrentedit.



Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Thanks Chrissie1!!

I tried the bindingcontext(datasetname).endcurrentedit along with the dataadapter.update(datasetname) but it isn't working for me...
 
did you correctly set the update-,insert- and deletecommand of the dataadapter?

What error message are you getting and give the code you used to make the update.

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Chrissie1 -

I'm not getting any errors on the adapters. What I have is one form with two adapters one dataset because there were too many rows in my table for one adapter.

I just don't get any data added to either of my tables.

Private Sub frmProducer_profile(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Dim dialogResult As DialogResult
dialogResult = MessageBox.Show("Do you want to exit saving changes?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
If dialogResult = dialogResult.No Then
e.Cancel = True
Else
BindingContext(ds_profiles).EndCurrentEdit()
da_profiles.Update(ds_profiles)
da_profiles1.Update(ds_profiles)
End If
End Sub
 
are the datasets bound to datagrid then perhaps you need to do this

datagrid1.bindingcontext(dsprofiles).endcurrentedit

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
No, my datasets aren't bound to a datagrid. I had it working that way when I did have the datagrid but then my boss didn't like the look and wanted 1 form instead.

I can't get it working and have a deadline of Wednesday.

I've only taken on vb.net course and they think I actually know vb. Tried to tell them I don't enough to do this but...

Thanks for hanging in there with me..
 
That's what I'm here for.

lets debug it then before you run it set a breakpoint on the bindingcontext then add these two watches.

the first one on one of the textboxes that you just updated and the other on the datasetfield that corresponds to that textbox. See if the two are the same. then do F11 look at the values again and once again F11 look at them agian if thay are still differnt after the third time then we know we have a problem we just have to find a solution.

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top