Imports System.Data.SqlClient Imports System.Data.SqlDbType Imports FastReport Public Class Form1 Public Connectionstring Dim dsreport As New DataSet Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Connectionstring = Configuration.ConfigurationManager.ConnectionStrings("LPConnectionString").ConnectionString Me.ToolStripComboBox1.Items.Clear() dsreport.ReadXml(Application.StartupPath + "\Auswertungen.xml") For Each dr As DataRow In dsreport.Tables(0).Rows Me.ToolStripComboBox1.Items.Add(dr.Item(0)) Next End Sub Private Sub ToolStripComboBox1_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripComboBox1.SelectedIndexChanged For Each dr As DataRow In dsreport.Tables(0).Rows If dr.Item(0) = ToolStripComboBox1.SelectedItem Then Design_Report(dr.Item(1), dr.Item(2), dr.Item(3)) End If Next End Sub Sub Design_Report(ByVal sql As String, ByVal sqltype As String, ByVal filename As String) Dim ds As New DataSet filename = Configuration.ConfigurationManager.AppSettings("Reportpfad") + "\" + filename If sqltype = "SP" Then ds = Get_Tabledata(sql, True, False) Else If sqltype = "SQL" Then ds = Get_Tabledata(sql, False, True) Else ds = Get_Tabledata(sql, False, False) End If End If Dim report As New Report Try If filename <> "" Then report.Load(filename) report.RegisterData(ds) report.GetDataSource("Daten").Enabled = True report.SetParameterValue("Parcours", Get_Option(2)) report.SetParameterValue("Spruch", Get_Option(3)) report.Design() report.Dispose() Catch ex As Exception MsgBox(ex.Message) End Try End Sub Public Function Get_Tabledata(ByVal Tablename As String, Optional StoredProc As Boolean = False, Optional is_SQL_String As Boolean = False) As DataSet Dim sqlconnect As New SqlConnection Dim ds As New DataSet ds.Tables.Clear() sqlconnect.ConnectionString = Me.Connectionstring sqlconnect.Open() Dim da As New SqlDataAdapter("", sqlconnect) Dim sqlcmd As New SqlCommand sqlcmd.Connection = sqlconnect If StoredProc = True Then sqlcmd.CommandType = CommandType.StoredProcedure sqlcmd.CommandText = Tablename Else sqlcmd.CommandType = CommandType.Text sqlcmd.CommandText = "Select * from " + Tablename End If If is_SQL_String = True Then sqlcmd.CommandText = Tablename End If ' sqlcmd.CommandType = CommandType.StoredProcedure ' sqlcmd.CommandText = "Berufsliste" da.SelectCommand = sqlcmd da.Fill(ds, "Daten") Return ds End Function Public Function Get_Option(ByVal onr As Integer) As String Try Dim sqlconnect As New SqlConnection Dim ds As New DataSet ds.Tables.Clear() sqlconnect.ConnectionString = Me.Connectionstring sqlconnect.Open() Dim da As New SqlDataAdapter("", sqlconnect) Dim sqlcmd As New SqlCommand sqlcmd.Connection = sqlconnect sqlcmd.CommandType = CommandType.Text sqlcmd.CommandText = "Select * from optionen where optionnr=" + onr.ToString da.SelectCommand = sqlcmd da.Fill(ds, "Daten") Return ds.Tables(0).Rows(0).Item("Inhalt") Catch ex As Exception Return "" 'MsgBox(ex.Message) End Try End Function Private Sub ToolStripComboBox1_Click_1(sender As System.Object, e As System.EventArgs) Handles ToolStripComboBox1.Click End Sub End Class