Page 1 of 1

how to connect to report by code

Posted: Wed Sep 16, 2009 9:50 am
by redahashem
im new at Stimulsoft Reports.Net and tryed to read help but didnot find what i want
this code i use it to conect
Dim cn As New OleDbConnection("provider=microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\Nwind2.accdb")
cn.Open()
Dim sql1 As String
Dim adp As OleDbDataAdapter
Dim da As New DataSet
sql1 = "select EmployeeID,LastName,FirstName from Employees where(Employees.EmployeeID=" & Me.TextBox1.Text & ")"
adp = New OleDbDataAdapter(sql1, cn)
adp.Fill(da, "Employees")
StiReport1.Load("StiReport1.mrt")

StiReport1.Dictionary.Databases.Clear()
StiReport1.Dictionary.DataSources.Clear()
StiReport1.RegData("da", da)
StiReport1.Dictionary.Synchronize()



StiReport1.Show()

so i must put all the text for all table.field when design report


this code didnot work also i use it with crystal report and worked well


how to connect to report by code

Posted: Wed Sep 16, 2009 4:11 pm
by Brendan
This line here:

Code: Select all

StiReport1.RegData("da", da)
You need to make sure the first parameter matches your datasource when you originally created the report.
Looking at your previous code, maybe this needs to be

Code: Select all

StiReport1.RegData("Employees", da)

how to connect to report by code

Posted: Wed Sep 16, 2009 4:44 pm
by redahashem
still give me this message

c:\Documents and Settings\lighto soft\Local Settings\Temp\ikhavnwt.0.cs(56,40) : error CS0103: The name 'DataSource1' does not exist in the current contextc:\Documents and Settings\lighto soft\Local Settings\Temp\ikhavnwt.0.cs(61,40) : error CS0103: The name 'DataSource1' does not exist in the current contextc:\Documents and Settings\lighto soft\Local Settings\Temp\ikhavnwt.0.cs(66,40) : error CS0103: The name 'DataSource1' does not exist in the current context


can any tell how to do that im tired
:waaaht: :sweat:

how to connect to report by code

Posted: Thu Sep 17, 2009 2:05 am
by jayanthi
Hai,

1. Create Connection as cn, DataSource as Employees in DataDictionary in ur report.
2. Use the following in ur code:

Dim cn As New OleDbConnection("provider=microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\Nwind2.accdb")
cn.Open()
Dim sql1 As String
Dim adp As OleDbDataAdapter
Dim da As New DataSet
sql1 = "select EmployeeID,LastName,FirstName from Employees where(Employees.EmployeeID=" & Me.TextBox1.Text & ")"
adp = New OleDbDataAdapter(sql1, cn)
adp.Fill(da)
StiReport1.Load("StiReport1.mrt")
da.Tables.Item(0).TableName = "Employees"
StiReport1.DataSources.Clear()
StiReport1.Dictionary.Databases.Clear()
StiReport1.RegData("DataSource", da.Tables("Employees"))
StiReport1.Dictionary.Synchronize()
StiReport1.Render(False)
StiViewerControl1.Report = StiReport1

Regards
Jay

how to connect to report by code

Posted: Thu Sep 17, 2009 8:53 am
by redahashem
thank u so much you great
it works fine but the report font changed to other font every time when i filter the data want the report keep the selected
font when i filter the report





:feelgood: :feelgood: :feelgood:

how to connect to report by code

Posted: Thu Sep 17, 2009 11:38 pm
by jayanthi
I have tried a sample, font is not getting changed for me.

Can you explain me with some more information.

Regards
Jay