Crystal Reports Datasource
I have an external application that I connect to, unfortuantly for some reason both VB.net and Crystal Reports does not like connecting to it using Add New Datasource Wizard or the GUI's, so for my .net application I connect to it using code as follows..
Dim connectionstring As String
Dim querystring As String
Dim mods3 = New DataSet()
Dim i As Integer
Try
connectionstring = "DSN=MyDatabase; UID=" & TxtUN.Text & "; PWD=" & TxtPassword.Text
querystring = "SELECT * FROM MyTable "
querystring &= " ORDER BY MyField1 ASC "
Dim command As New Odbc.OdbcCommand(querystring)
Using connection As New Odbc.OdbcConnection(connectionstring)
command.Connection = connection
connection.Open()
command.ExecuteNonQuery()
'MessageBox.Show("Targets updated successfully")
End Using
Dim oAdapter As Odbc.OdbcDataAdapter
Try
oAdapter = _
New Odbc.OdbcDataAdapter(querystring, connectionstring)
oAdapter.Fill(mods3, "Downtime")
'MessageBox.Show("Targets updated successfully")
Catch oExcept As Exception
'MessageBox.Show("Targets not updated")
End Try
Catch ex As Exception
MsgBox(vbCrLf & ex.Message)
End Try
This works fine, I can use the populated dataset to return the values I need to specific fields on my form.
My question is this, can I use the above method so that I can create a crystal report? I know how to use code from a VB.Net form to pass parameters into a Crystal Report such as.
Dim dlgORpt As New ReportViewer dlgORpt.StoresListing1.SetParameterValue("MyParameter", MyParameter.Text)
dlgORpt.ShowDialog()
I just cant figure out how to create the datasorce for a crystal report programically as above..
Any help would be appreciated.
Cheers
Dougie

