Dataset population question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I wonder can someone tell me if it is possible to use 2 databases(.sdf) to return the rows i want for my grid. How does the connections work. As you can see from the code below i use only 1 db connection and default QUANTITY to zero. In fact, QUANTITY must come from an Orders DB under the OrdersDBconnection. How can I do this??

here is my code...

sqlDS = New DataSet

' TODO: Quantity will come from OrdersDB, maybe need to pass twice!
Dim strSQL As String = "Select 0 QUANTITY,ITEMDESC, a.ITEMNMBR ITEMNMBR FROM Products a, CustomerProducts b " & _
" WHERE a.itemnmbr = b.itemnmbr and PRCLEVEL = '" + prclevel + "'" & _
" order by PICKSEQ"

sqlDA = New SqlCeDataAdapter(strSQL, GenericDBconnection)
sqlDA.Fill(sqlDS, "Products")

If VerifyDBConnection(GenericDBconnection) = False Then
Return -1
End If

dgLines.DataSource = sqlDS.Tables("Products")

'sqlDA.Update(sqlDS)

Dim ts As New DataGridTableStyle
ts.MappingName = "Products"

Dim qty As New DataGridTextBoxColumn
qty.MappingName = "QUANTITY"
qty.HeaderText = "Qty"
qty.Width = 50
ts.GridColumnStyles.Add(qty)

Dim item As New DataGridTextBoxColumn
item.MappingName = "ITEMDESC"
item.HeaderText = "Item Description"
item.Width = 150
ts.GridColumnStyles.Add(item)

Dim itemcode As New DataGridTextBoxColumn
itemcode.MappingName = "ITEMNMBR"
itemcode.HeaderText = "Item Code"
itemcode.Width = 1
ts.GridColumnStyles.Add(itemcode)

dgLines.TableStyles.Clear()
dgLines.TableStyles.Add(ts)

GenericDBconnection.Close()

Please help :(
 
I"m not following you here. With two dbs, you need to create two connection
objects with two different connection strings, or you can use the
..ChangeDatabase method (supported only under 1.1 framework for both SQL and
SQL CE)
http://msdn.microsoft.com/library/d...ataSqlServerCeSqlCeConnectionMethodsTopic.asp
Call fill on the one dataaset and then use another adapter to fill it with
data from the other db Remember that the dataset doesn't care where it gets
its data from so you can easily fill it with data from multiple places. The
majority of your code has to do with UI stuff so I'm not posititve I've
answered the question in that i'm not positive I understand it - if I
didn't, please let me know and I'll do my best to answer it.
--

W.G. Ryan, eMVP

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
marcmc said:
I wonder can someone tell me if it is possible to use 2 databases(.sdf) to
return the rows i want for my grid. How does the connections work. As you
can see from the code below i use only 1 db connection and default QUANTITY
to zero. In fact, QUANTITY must come from an Orders DB under the
OrdersDBconnection. How can I do this??
here is my code...

sqlDS = New DataSet

' TODO: Quantity will come from OrdersDB, maybe need to pass twice!
Dim strSQL As String = "Select 0 QUANTITY,ITEMDESC, a.ITEMNMBR
ITEMNMBR FROM Products a, CustomerProducts b " & _
 
I cant seem to get the dbchange to work...

What I have are sales order lines on a table called OrderDtl on an OrdersDbConnection. This table holds itemcode, quantity etc. I need the quantity for a specific order number (which i have) to insert into the datagrid under quantity and in the right place in relation to its associated product code and description on the order.

The product code and description comes from a Products table in a a GenericDbConnection and fills the dataset as in the code i posted above. The itemcode can link both tables in each database. I have used nested datareaders to get these details into listViews before. I have not tried it with the DA/DS. I understand that I can fill use two DA's but am not sure how to append the products details onto the qty details and in the right places eg(line 1 of order has quantity 10 for itemnmbr xyz. All existing products are put into the datagrid but only some will have quantities assigned to them when i enter the datagrid in edit mode. Users then add, update and delete quantities and lines with already working code.
 
Back
Top