1 Replies - 1179 Views - Last Post: 29 November 2012 - 07:54 AM Rate Topic: -----

#1 vijaycare  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 05-April 12

Filling a Dataset using sql at runtime in vb.net

Posted 29 November 2012 - 06:52 AM

Dear All,

I have a dataset to create crystal report.
The data I have used is depends on the selection of database(3nos) which contains same tables and columns and keys.
So I have created a dataset thru designer in vb 2005 and add tables like the database to load the data thru sql statement with parameter using access database. The sql statement works fine.

The Sql statement is under the code section

 Dim sql1 As String = "SELECT Delivery.DelID, Delivery.DelDate, OPDDetails.BatchNo, OPDDetails.BatchDate," & _
            " OPDDetails.Packs, OPDDetails.LPacks, OPDDetails.NetQty, Products.ProdName, Brands.BrClass, Brands.BrDivision," & _
            " Customers.CustName, Customers.Village, Customers.RCNo, Customers.SurveyNo, Trucks.TruckNo, Trucks.License," & _
            " Trucks.ValidTill, Godown.LicenseNo, Godown.Village, Godown.Taluk, Units.UnitSName FROM Units INNER JOIN" & _
            " (Trucks INNER JOIN (Products INNER JOIN (Godown INNER JOIN ((Customers INNER JOIN Delivery ON" & _
            " Customers.CustID=Delivery.CustID) INNER JOIN (Brands INNER JOIN OPDDetails ON Brands.BrID=OPDDetails.BrandID)" & _
            " ON Delivery.DelID=OPDDetails.DelID) ON Godown.GodID=OPDDetails.GID) ON Products.ProdID=Brands.ProdID) ON" & _
            " Trucks.TruckID=Delivery.TruckID) ON Units.UnitID=Products.UnitID WHERE Delivery.DelID = @DID AND OPDDetails.NetQty >0"
            Dim daDelivery As New OleDb.OleDbDataAdapter(sql1, con.Conn)
            daDelivery.SelectCommand.Parameters.AddWithValue("@DID", Me.txtID.Text)
            Dim dsDelivery As New DataSet
            dsDelivery.Clear()
            daDelivery.Fill(dsDelivery, "Delivery")



How can i load the data in the dataset's virtual table.
I have used a connection class which defines which database should be load

Dim FilePath As String = "D:\ESoft\" & frmMain.ToolStripStatuslblGodown.Text & ".mdb" & ";Jet OLEDB:Database Password= admin"
    Public ConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source = " & FilePath
    Public Conn As New OleDb.OleDbConnection(ConnString)



Any suggestion would be appreciated

Is This A Good Question/Topic? 0
  • +

Replies To: Filling a Dataset using sql at runtime in vb.net

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9204
  • View blog
  • Posts: 34,581
  • Joined: 12-June 08

Re: Filling a Dataset using sql at runtime in vb.net

Posted 29 November 2012 - 07:54 AM

Have you checked out our tutorials?
OleDb Basics in VB.Net

A Really Simple Database Create a Database using Access & VB.net Express 2008
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1