I am looking to pull data from a access db, and have it spit out in to a VB Report. First to test I use this code to fill a datagridview:
Code
rivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'TODO: This line of code loads data into the 'NbxcdrDataSet.CallData' table. You can move, or remove it, as needed.
' Me.CallDataTableAdapter.Fill(Me.NbxcdrDataSet.CallData)
Dim conn As OleDbConnection = New OleDbConnection
Dim da As OleDbDataAdapter
Dim ds As DataSet
Dim cb As OleDbCommandBuilder
Dim dateSel As String = DateTimePicker1.Text
Dim extStr = TextBox1.Text
If TextBox1.Text = "" Then
MsgBox("Please enter and Extension")
Else
conn.ConnectionString = ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\spabramenko\My Documents\Visual Studio 2008\Projects\NBX Calls\NBX Calls\bin\Debug\nbxcdr.accdb;Persist Security Info=False;")
conn.Open()
Dim sqlString As String = ("Select Date, P1Id, P1Name, P2Id, P2Name, StartTime, Duration, P1CallerId, P1DialDigit, P2CallerId, P2DialDigit from calldata where ((date) = #" & dateSel & "# And (P1Id) = " & extStr & ")")
'Dim sqlString As String = ("Select Date, P1Id from calldata where ((date) = #" & dateSel & "#)")
da = New OleDbDataAdapter(sqlString, conn)
'da = New OleDbDataAdapter("Select Date, P1Id from calldata where ((date) = date() -3)", conn)
' WHERE (((Date)=Date()-1)
cb = New OleDbCommandBuilder(da)
ds = New DataSet
da.Fill(ds, "calldata")
DataGridView1.DataSource = ds.Tables("calldata")
DataGridView1.Show()
End If
End Sub
This works great. It displays what I want. Then I use the report wizard, to generate a report from that db file, and it spits it to a report. But it puts everything in the report with this code:
Me.CallDataTableAdapter.Fill(Me.nbxcdrDataSet.CallData)
Me.ReportViewer1.RefreshReport()
When I say everything I mean it does not use the dataset from the first posted code. I want to be able to run the sql statement and have the results back into the report if possible. Thanks.
Code
'TODO: This line of code loads data into the 'NbxcdrDataSet.CallData' table. You can move, or remove it, as needed.
' Me.CallDataTableAdapter.Fill(Me.NbxcdrDataSet.CallData)
Dim conn As OleDbConnection = New OleDbConnection
Dim da As OleDbDataAdapter
Dim ds As DataSet
Dim cb As OleDbCommandBuilder
Dim dateSel As String = DateTimePicker1.Text
Dim extStr = TextBox1.Text
If TextBox1.Text = "" Then
MsgBox("Please enter and Extension")
Else
conn.ConnectionString = ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\spabramenko\My Documents\Visual Studio 2008\Projects\NBX Calls\NBX Calls\bin\Debug\nbxcdr.accdb;Persist Security Info=False;")
conn.Open()
Dim sqlString As String = ("Select Date, P1Id, P1Name, P2Id, P2Name, StartTime, Duration, P1CallerId, P1DialDigit, P2CallerId, P2DialDigit from calldata where ((date) = #" & dateSel & "# And (P1Id) = " & extStr & ")")
'Dim sqlString As String = ("Select Date, P1Id from calldata where ((date) = #" & dateSel & "#)")
da = New OleDbDataAdapter(sqlString, conn)
'da = New OleDbDataAdapter("Select Date, P1Id from calldata where ((date) = date() -3)", conn)
' WHERE (((Date)=Date()-1)
cb = New OleDbCommandBuilder(da)
ds = New DataSet
da.Fill(ds, "calldata")
DataGridView1.DataSource = ds.Tables("calldata")
DataGridView1.Show()
End If
End Sub
This works great. It displays what I want. Then I use the report wizard, to generate a report from that db file, and it spits it to a report. But it puts everything in the report with this code:
Me.CallDataTableAdapter.Fill(Me.nbxcdrDataSet.CallData)
Me.ReportViewer1.RefreshReport()
When I say everything I mean it does not use the dataset from the first posted code. I want to be able to run the sql statement and have the results back into the report if possible. Thanks.