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

Dataset wondering

Status
Not open for further replies.

aspvbnetnerd

Programmer
May 16, 2006
278
SE
I have always worked with DataReader and It have worked fine, but know I forced to use DataSet.

I have google around a little.
With this simple sql question the The DataSet is filled from everything from the "Employees" table
Code:
Dim conStr As String = "Provider=Microsoft.JET.OLEDB.4.0;data source=c:\\northwind.mdb"
Dim conn As OleDbConnection = New OleDbConnection(conStr)
Dim sqlStr As String = "SELECT * FROM Employees"

Dim da As OleDbDataAdapter = New OleDbDataAdapter(sqlStr, conn)  

Dim ds As DataSet = New DataSet
da.Fill(ds, "Employees")

But What I Have T-Sql that is different. Maybee like this
Code:
SELECT	CB.RUBRIC As CARDBOARDRUBRIC, C.CUSTOMERID, A.ASSIGNMENTID, CB.CARDBOARDID, BU.SCANNINGSTATIONID,
		CASE LEN(A.DOCUMENTTYPEID)
			WHEN 1 THEN CAST(A.RUBRIC AS VARCHAR(10)) + ' 0' + CAST(A.DOCUMENTTYPEID AS nVarchar(1))
			WHEN 2 THEN CAST(A.RUBRIC AS VARCHAR(10)) + ' ' + CAST(A.DOCUMENTTYPEID AS nVarchar(2))
		END AS RUBRIC,
		MIN(BU.SCANNINGDATE) AS MINSCANDATE, MAX(BU.SCANNINGDATE) AS MAXSCANDATE, 
		MIN(BU.FIRSTSERIALNUMBER) AS MINNUMBER, 
		CASE 
			WHEN MIN(BU.LASTSERIALNUMBER) < MAX(BU.FIRSTSERIALNUMBER) AND MAX(BU.FIRSTSERIALNUMBER) > 99000 THEN MIN(BU.LASTSERIALNUMBER)
			ELSE MAX(BU.LASTSERIALNUMBER)
		END AS MAXNUMBER
FROM	CARDBOARD CB
			INNER JOIN BUNTCH BU ON BU.CARDBOARDID = CB.CARDBOARDID 
			INNER JOIN ASSIGNMENT A ON A.ASSIGNMENTID = CB.ASSIGNMENTID
			INNER JOIN CUSTOMER C ON C.CUSTOMERID = A.CUSTOMERID
WHERE	CB.CARDBOARDID = @CARDBOARDID
AND		(BU.LOST IS NULL OR BU.LOST = 0)
GROUP BY C.CUSTOMERID, A.ASSIGNMENTID, CB.CARDBOARDID, 
		 A.RUBRIC, A.DOCUMENTTYPEID, CB.RUBRIC, BU.SCANNINGSTATIONID
What should I do then in
Code:
[COLOR=red]da.Fill(ds, "Employees")[/color]


Please help me. :-(
George
 
Bear in mind that a DataSet does not have to reflect the actual Table structure in a database. A DataSet can contain 0 or more DataTables, which again, don't have to reflect the actual structure of a database. You can use something like the following: da.Fill(ds, "WhateverYouWantToNameYourDataTable")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top