هلا انا بستخدم داتا بيس Northwind SQL2000
و Visual Basic 2005
وبدي اقراء الصور من الداتا بيس و اعرضها بالفورم
بحثت في المنتدى والقيت حلول بس مازبطو عندي
المهم هذا هو كود المشروع كلة
Public Class Form1
Dim con As New SqlClient.SqlConnection("Integrated Security=true" & _
";Initial Catalog=Northwind;" & _
"Data Source=LocalhosT")
Dim da As New SqlClient.SqlDataAdapter("select * from Categories", con)
Dim ds As New DataSet
Dim i As Integer
Dim ii As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'
'Load
'
da.Fill(ds)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'
'View
'
Me.DataGridView1.DataSource = ds.Tables(0)
MsgBox("Rows :" & Me.ds.Tables(0).Rows.Count.ToString)
Me.TextBox4.Text = Me.ds.Tables(0).Rows.Count
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'
'<
'
If Me.ds.Tables(0).Rows.Count.ToString = Me.TextBox1.Text Then
MsgBox("There Are No More Rows")
Else
i += 1
Me.TextBox1.Text = Me.ds.Tables(0).Rows(i - 1)(0)
Me.TextBox2.Text = Me.ds.Tables(0).Rows(i - 1)(1)
Me.TextBox3.Text = Me.ds.Tables(0).Rows(i - 1)(2)
Try
Dim Dataaray() As Byte = ds.Tables(0).Rows(i - 1)(3)
Dim mems As New IO.MemoryStream(Dataaray)
Me.PictureBox1.Image = Image.FromStream(mems)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
'
'>
'
If Me.ds.Tables(0).Rows.Count.ToString + 1 = Me.TextBox1.Text Or _
Me.TextBox1.Text = "" Or Me.TextBox1.Text = "1" Then
MsgBox("There Are No More Rows")
Else
ii = Me.TextBox1.Text
i -= 1
Me.TextBox1.Text = Me.ds.Tables(0).Rows(i - 1)(0)
Me.TextBox2.Text = Me.ds.Tables(0).Rows(i - 1)(1)
Me.TextBox3.Text = Me.ds.Tables(0).Rows(i - 1)(2)
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'
'Fill
'
If Me.DataGridView1.SelectedRows.Count = 0 Then
MsgBox("Pleas Select At Least One Row")
Else
Me.TextBox1.Text = Me.DataGridView1.SelectedRows.Item(0).Cells(0).Value
Me.TextBox2.Text = Me.DataGridView1.SelectedRows.Item(0).Cells(1).Value
Me.TextBox3.Text = Me.DataGridView1.SelectedRows.Item(0).Cells(2).Value
End If
End Sub
End Classهلا المشكلة في الكود هذا
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'
'<
'
If Me.ds.Tables(0).Rows.Count.ToString = Me.TextBox1.Text Then
MsgBox("There Are No More Rows")
Else
i += 1
Me.TextBox1.Text = Me.ds.Tables(0).Rows(i - 1)(0)
Me.TextBox2.Text = Me.ds.Tables(0).Rows(i - 1)(1)
Me.TextBox3.Text = Me.ds.Tables(0).Rows(i - 1)(2)
Try
Dim Dataaray() As Byte = ds.Tables(0).Rows(i - 1)(3)
Dim mems As New IO.MemoryStream(Dataaray)
Me.PictureBox1.Image = Image.FromStream(mems)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
End Subكل ما ضغط يطلعلي الخطاء التالي بس بالنسبة للصورة اما باقي الاشياء ماشي تمام
---------------------------
Parameter is not valid.
---------------------------
حاولت كثير بس من غير نتيجة
ممكن حد يساعدني
وشكررررررررررررررررررررررررررررررررررررررر