Results 1 to 11 of 11

Thread: Need help how to fill my selected field to dataset using access and having JOIN CONn

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2007
    Posts
    839

    Question Need help how to fill my selected field to dataset using access and having JOIN CONn

    HELP ME HERE HOW TO FILL IT TO THE DATASET...

    USING JOIN CONNECTION...
    HERE IS MY CODES..


    Private Sub GetRecords(ByVal UsePrinRSONO As String)

    Dim cmd As New OleDbCommand
    cmd.Connection = cn
    cmd.CommandType = CommandType.Text
    cmd.CommandText = "SELECT Sheet1.RsoNo, Sheet1.Customer, Sheet3.ItemCode, Sheet3.ItemDescription, Sheet3.Source, Sheet3.MOQ, Sheet3.QuantityRequired, Sheet3.Remarks, Sheet1.ZeroStock, Sheet1.NewProduct, Sheet1.ProjectForecast, Sheet1.WithMotherPO, Sheet1.Others, Sheet1.RequestedBy, Sheet1.NotedBy, Sheet1.RecievedBy FROM Sheet1 INNER JOIN Sheet3 ON Sheet1.RsoNo = Sheet3.RsoNo where RSONO ='" & UsePrinRSONO & "';"
    da = New OleDbDataAdapter
    da.SelectCommand = cmd
    da.Fill(ds, "Sheet1.RsoNo, Sheet1.Customer, Sheet3.ItemCode, Sheet3.ItemDescription, Sheet3.Source, Sheet3.MOQ, Sheet3.QuantityRequired, Sheet3.Remarks, Sheet1.ZeroStock, Sheet1.NewProduct, Sheet1.ProjectForecast, Sheet1.WithMotherPO, Sheet1.Others, Sheet1.RequestedBy, Sheet1.NotedBy, Sheet1.RecievedBy FROM Sheet1 INNER JOIN Sheet3 ON Sheet1.RsoNo = Sheet3.RsoNo")

    End Sub


    THIS IS MY PROBLEM... FILLING THE SELECTION FEILDS..

    da.Fill(ds, "Sheet1.RsoNo, Sheet1.Customer, Sheet3.ItemCode, Sheet3.ItemDescription, Sheet3.Source, Sheet3.MOQ, Sheet3.QuantityRequired, Sheet3.Remarks, Sheet1.ZeroStock, Sheet1.NewProduct, Sheet1.ProjectForecast, Sheet1.WithMotherPO, Sheet1.Others, Sheet1.RequestedBy, Sheet1.NotedBy, Sheet1.RecievedBy FROM Sheet1 INNER JOIN Sheet3 ON Sheet1.RsoNo = Sheet3.RsoNo")

    HELP ME PLEASE..?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Need help how to fill my selected field to dataset using access and having JOIN CONn

    The second parameter to he Fill method needs to be the name of the DataTable you want to populate in the DataSet, not a query. Had you read the Help documentation for that method you would know this.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2007
    Posts
    839

    Re: Need help how to fill my selected field to dataset using access and having JOIN CONn

    ok so here is my datatable

    i declare it to private

    private dt as datatable


    Private Sub GetRecords(ByVal UsePrinRSONO As String)

    Dim cmd As New OleDbCommand
    cmd.Connection = cn
    cmd.CommandType = CommandType.Text
    cmd.CommandText = "SELECT Sheet1.RsoNo, Sheet1.Customer, Sheet3.ItemCode, Sheet3.ItemDescription, Sheet3.Source, Sheet3.MOQ, Sheet3.QuantityRequired, Sheet3.Remarks, Sheet1.ZeroStock, Sheet1.NewProduct, Sheet1.ProjectForecast, Sheet1.WithMotherPO, Sheet1.Others, Sheet1.RequestedBy, Sheet1.NotedBy, Sheet1.RecievedBy FROM Sheet1 INNER JOIN Sheet3 ON Sheet1.RsoNo = Sheet3.RsoNo where RSONO ='" & UsePrinRSONO & "';"
    da = New OleDbDataAdapter
    da.SelectCommand = cmd
    da.Fill(ds, "Sheet1.RsoNo, Sheet1.Customer, Sheet3.ItemCode, Sheet3.ItemDescription, Sheet3.Source, Sheet3.MOQ, Sheet3.QuantityRequired, Sheet3.Remarks, Sheet1.ZeroStock, Sheet1.NewProduct, Sheet1.ProjectForecast, Sheet1.WithMotherPO, Sheet1.Others, Sheet1.RequestedBy, Sheet1.NotedBy, Sheet1.RecievedBy FROM Sheet1 INNER JOIN Sheet3 ON Sheet1.RsoNo = Sheet3.RsoNo")
    da.fill(dt)
    End Sub

    is that look like this..?

    if not how it look like..?

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Need help how to fill my selected field to dataset using access and having JOIN CONn

    Firstly, if you're doing this:
    Code:
    da.fill(dt)
    then why are you doing this immediately before it:
    Code:
    da.Fill(ds, "Sheet1.RsoNo, Sheet1.Customer, Sheet3.ItemCode, Sheet3.ItemDescription, Sheet3.Source, Sheet3.MOQ, Sheet3.QuantityRequired, Sheet3.Remarks, Sheet1.ZeroStock, Sheet1.NewProduct, Sheet1.ProjectForecast, Sheet1.WithMotherPO, Sheet1.Others, Sheet1.RequestedBy, Sheet1.NotedBy, Sheet1.RecievedBy FROM Sheet1 INNER JOIN Sheet3 ON Sheet1.RsoNo = Sheet3.RsoNo")
    Secondly, you've declared a DataTable variable named 'dt' in that code but at no point have you assigned a DataTable object to it, so this will fail:
    Code:
    da.fill(dt)
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2007
    Posts
    839

    Re: Need help how to fill my selected field to dataset using access and having JOIN CONn

    i really don't undertand... help me please. i'm just new here i'm njot really familliar of all method here..

    how could i FILL this into the dataset? because in my sql code samely like that code in my second application made..

    here it is...


    Private Sub GetRecords(ByVal ApplicantID As String)

    Dim cmd As New SqlCommand
    cmd.Connection = cn
    cmd.CommandType = CommandType.Text
    cmd.CommandText = "Select * from ApplicantProfile where ApplicantID = '" & ApplicantID & "'"
    da = New SqlDataAdapter
    da.SelectCommand = cmd
    da.Fill(ds, "ApplicantProfile")
    End Sub

    it's really the same that is in sql and it work fine...

    why in this case it's not..?

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2007
    Posts
    839

    Re: Need help how to fill my selected field to dataset using access and having JOIN CONn

    by the i'm doing this

    da.Fill(ds, "Sheet1.RsoNo, Sheet1.Customer, Sheet3.ItemCode, Sheet3.ItemDescription, Sheet3.Source, Sheet3.MOQ, Sheet3.QuantityRequired, Sheet3.Remarks, Sheet1.ZeroStock, Sheet1.NewProduct, Sheet1.ProjectForecast, Sheet1.WithMotherPO, Sheet1.Others, Sheet1.RequestedBy, Sheet1.NotedBy, Sheet1.RecievedBy FROM Sheet1 INNER JOIN Sheet3 ON Sheet1.RsoNo = Sheet3.RsoNo")


    because i want to fill it to the datatable then i want display it to the datagrid
    this adding this code below on that..

    me.datagridview1.datasource = dt
    that is why i'm using dt as my datatable...

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Need help how to fill my selected field to dataset using access and having JOIN CONn

    You aren't really reading what I'm posting. You are supposed to specify the name of a DataTable. Is this:
    "Sheet1.RsoNo, Sheet1.Customer, Sheet3.ItemCode, Sheet3.ItemDescription, Sheet3.Source, Sheet3.MOQ, Sheet3.QuantityRequired, Sheet3.Remarks, Sheet1.ZeroStock, Sheet1.NewProduct, Sheet1.ProjectForecast, Sheet1.WithMotherPO, Sheet1.Others, Sheet1.RequestedBy, Sheet1.NotedBy, Sheet1.RecievedBy FROM Sheet1 INNER JOIN Sheet3 ON Sheet1.RsoNo = Sheet3.RsoNo"
    the name of a DataTable?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2007
    Posts
    839

    Re: Need help how to fill my selected field to dataset using access and having JOIN CONn

    ah ok by the way... how could put the table in this case that i'm using two table here.... because it's the data combination of sheet1 and sheet3..

    so, as far as your posting concerned.. since i have two tables wheich of them should i use (sheet1 or sheet3)..?

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Need help how to fill my selected field to dataset using access and having JOIN CONn

    As I have said, it is the the name of the DataTable that you want to populate, NOT the name of the database table you're retrieving the data from. It is common practice to use the same name for both but there is no requirement that it be so. Obviously if the source is more than one table then it's impossible to do so. You can specify any name you want for your DataTable, although you should pick something that is meaningful under the circumstances.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2007
    Posts
    839

    Re: Need help how to fill my selected field to dataset using access and having JOIN CONn

    hi, thank you very much... i got correct to do my problem...

    how could i rate you..?

    but anyway i have other problem with my report form everytime i press print button it will generate new form instead of refresh my report form..

    how could i do my report form will refresh instead of openning new one..
    i don't want to open new one i like refresh on the form itself..



    here is my code calling my report form...


    Private Sub Print_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


    Dim newRep As New CrystalReportFillBy
    OpenConnection()
    GetRecords(UsePrintRSONO_rpt)
    newRep.SetDataSource(ds)
    newRep.Refresh()
    CrystalReportViewer1.RefreshReport()

    end sub


    Private Sub BtnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnPrint.Click
    If cboPrintRsoNo.Text = "" Then
    MessageBox.Show("Please Put RSONO Number to print The Data")
    Exit Sub
    End If
    Dim fr As New PrintFinal
    fr.UsePrintRSONO_rpt = Me.cboPrintRsoNo.Text
    fr.Show()
    End Sub
    End Class

  11. #11
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Need help how to fill my selected field to dataset using access and having JOIN CONn

    Please keep each topic to one thread and each thread to one topic. If you have an unrelated question please start a new thread for it.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width