|
-
Oct 18th, 2007, 12:48 AM
#1
Thread Starter
Fanatic Member
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..?
-
Oct 18th, 2007, 12:54 AM
#2
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.
-
Oct 18th, 2007, 02:22 AM
#3
Thread Starter
Fanatic Member
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..?
-
Oct 18th, 2007, 02:32 AM
#4
Re: Need help how to fill my selected field to dataset using access and having JOIN CONn
Firstly, if you're doing this: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:
-
Oct 18th, 2007, 02:46 AM
#5
Thread Starter
Fanatic Member
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..?
-
Oct 18th, 2007, 03:04 AM
#6
Thread Starter
Fanatic Member
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...
-
Oct 18th, 2007, 03:09 AM
#7
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?
-
Oct 18th, 2007, 03:29 AM
#8
Thread Starter
Fanatic Member
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)..?
-
Oct 18th, 2007, 03:41 AM
#9
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.
-
Oct 18th, 2007, 05:11 AM
#10
Thread Starter
Fanatic Member
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
-
Oct 18th, 2007, 05:30 AM
#11
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|