-1
私は4つのコンボボックスとボタンを持つフォームを持っています。Crystal Report + VB net + Mysql ifおよびElsIfの数
- ライセンス
- メーカー
- タイプ
- スケール
がどのように私は、たとえば、他の2なしの値の2を選択することができます。このボタンは、コンボボックスの4つの値を検索します、メーカーとスケール?選択した値を検索して表示できるようにする必要があります。今、私はこのコードしか持っていませんが、私は4つの値が必要です。 if文combox1 =クエリ1、もしコンボ1 +コンボ3 =クエリ3、など......
If ComboBox1.Text = "All" Then
Me.Cursor = Cursors.WaitCursor
Try
Dim ds As New DataSet
Dim query As String
query = "select * from product order by id_maker asc, id_types asc, id_scale asc,name asc"
Dim dscmd As New MySqlDataAdapter(query, con)
dscmd.Fill(ds, "PAYPRODUCTTOTAL")
con.Close()
Dim cryds As New All_Database_Report
cryds.SetDataSource(ds.Tables(0))
CrystalReportViewer1.ReportSource = cryds
CrystalReportViewer1.Refresh()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
ElseIf ComboBox1.Text <> "All" Then
If ComboBox2.Text = Nothing Then
MsgBox("Select a Maker", MsgBoxStyle.Exclamation)
ElseIf ComboBox3.Text = Nothing Then
MsgBox("Select a Type", MsgBoxStyle.Exclamation)
ElseIf ComboBox4.Text = Nothing Then
MsgBox("Select a Scale", MsgBoxStyle.Exclamation)
Else
Try
Dim ds As New DataSet
Dim query As String
p(0) = New MySqlParameter("@License", MySqlDbType.String)
p(0).Value = ComboBox1.Text
p(1) = New MySqlParameter("@Maker", MySqlDbType.String)
p(1).Value = ComboBox2.Text
p(2) = New MySqlParameter("@Type", MySqlDbType.String)
p(2).Value = ComboBox3.Text
p(3) = New MySqlParameter("@Scale", MySqlDbType.String)
p(3).Value = ComboBox4.Text
query = "select * from product WHERE license = @License AND id_maker = @Maker AND id_types = @Type AND id_scale = @Scale order by id_maker asc, id_types asc, id_scale asc,name asc"
Dim dscmd As New MySqlDataAdapter(query, con)
dscmd.SelectCommand.Parameters.Add(p(0))
dscmd.SelectCommand.Parameters.Add(p(1))
dscmd.SelectCommand.Parameters.Add(p(2))
dscmd.SelectCommand.Parameters.Add(p(3))
dscmd.Fill(ds, "PAYPRODUCTTOTAL")
con.Close()
Dim cryds As New All_Database_Report
cryds.SetDataSource(ds.Tables(0))
CrystalReportViewer1.ReportSource = cryds
CrystalReportViewer1.Refresh()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End If
End If
Me.Cursor = Cursors.Default
Ok。私は後で試してみてください...共有のおかげで – Jamyz
ありがとうが、私は "StringBuilder"は定義されていない1つの問題があります。 ??なにか提案を ? – Jamyz
Imports System.Textは役に立ちます。 – EJD