10-04-13, 12:49 PM
طبعا هذا كود لتمرير المتغيرات من الفجوال بيسك الى الكريستال ريبورت
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
If matcmp.SelectedIndex <> -1 Or spoo.SelectedIndex <> -1 Or lc.SelectedIndex <> -1 Then
Dim y As String
y = matcmp.SelectedValue// المتغير الأول
Dim n As String
n = spoo.SelectedValue//المتغير الثاني
Dim f As String
f = lc.SelectedValue// المتغير الثالث
connectionString = "Data Source=DATABASE-SRV5;Initial Catalog=Assets;Integrated Security=True"
cnn = New SqlConnection(connectionString)
cnn.Open()
select_part = "SELECT Materials.Mat_ID, Materials.Ast_ID, Materials.Mat_Desc, Materials.Mat_Deactivated, Materials.Mat_WrittenOff, Materials.Mat_Sponsor, Materials_Statuse.Desc, Materials.Current_Loc, Locations.Desc FROM Assets.dbo.Materials_Statuse Materials_Statuse INNER JOIN (Assets.dbo.Locations Locations INNER JOIN Assets.dbo.Materials Materials ON Locations.Code=Materials.Current_Loc) ON Materials_Statuse.Code=Materials.Mat_Statuse"
where_part = " where true "
where_part = where_part + "And Materials.Mat_ID='" & y & "' And Materials.Mat_Sponsor= '" & n & "' And Materials.Current_Loc='" & f & "'"
sql = select_part + where_part
MsgBox(sql)
Dim dscmd As New SqlDataAdapter(sql, cnn)
DS.Clear()
MsgBox("open")
'***********************
dscmd.Fill(DS, "d")الخطأ هنا في دالة FILL ولا اعلم السبب الكود يطبق كله ماعدا هذه الدالة يظهر خطأ
DS.WriteXmlSchema("rpt.xml")
d = DS.Tables(0)
rpt.SetDataSource(d)
'**********************
With Me
.CrystalReportViewer1.ReportSource = rpt
.CrystalReportViewer1.RefreshReport()
.Show()
End With
End If
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
If matcmp.SelectedIndex <> -1 Or spoo.SelectedIndex <> -1 Or lc.SelectedIndex <> -1 Then
Dim y As String
y = matcmp.SelectedValue// المتغير الأول
Dim n As String
n = spoo.SelectedValue//المتغير الثاني
Dim f As String
f = lc.SelectedValue// المتغير الثالث
connectionString = "Data Source=DATABASE-SRV5;Initial Catalog=Assets;Integrated Security=True"
cnn = New SqlConnection(connectionString)
cnn.Open()
select_part = "SELECT Materials.Mat_ID, Materials.Ast_ID, Materials.Mat_Desc, Materials.Mat_Deactivated, Materials.Mat_WrittenOff, Materials.Mat_Sponsor, Materials_Statuse.Desc, Materials.Current_Loc, Locations.Desc FROM Assets.dbo.Materials_Statuse Materials_Statuse INNER JOIN (Assets.dbo.Locations Locations INNER JOIN Assets.dbo.Materials Materials ON Locations.Code=Materials.Current_Loc) ON Materials_Statuse.Code=Materials.Mat_Statuse"
where_part = " where true "
where_part = where_part + "And Materials.Mat_ID='" & y & "' And Materials.Mat_Sponsor= '" & n & "' And Materials.Current_Loc='" & f & "'"
sql = select_part + where_part
MsgBox(sql)
Dim dscmd As New SqlDataAdapter(sql, cnn)
DS.Clear()
MsgBox("open")
'***********************
dscmd.Fill(DS, "d")الخطأ هنا في دالة FILL ولا اعلم السبب الكود يطبق كله ماعدا هذه الدالة يظهر خطأ
DS.WriteXmlSchema("rpt.xml")
d = DS.Tables(0)
rpt.SetDataSource(d)
'**********************
With Me
.CrystalReportViewer1.ReportSource = rpt
.CrystalReportViewer1.RefreshReport()
.Show()
End With
End If
End Sub