تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
اين الخطا من فضلكم
#1
PHP كود :
Imports System.Data.SqlClient
Imports System
.IO
Public Class Form1
    Dim con 
As New SqlConnection("server=.; database =test; integrated security=true")
 
   Dim da As SqlDataAdapter
    Dim dt 
As New DataTable
    Dim cmd 
As New SqlCommand
    Dim dr 
As SqlDataReader
    Dim cmdb 
As New SqlCommandBuilder



    Private Sub ListBoxFill
()
 
       da = New SqlDataAdapter("select id , pdfname  from table_1 "con)
 
       da.Fill(dt)
 
       Me.ListBox1.DataSource dt
        Me
.ListBox1.ValueMember "id"
 
       Me.ListBox1.DisplayMember "pdfname"


 
   End Sub
    Private Sub Form1_Load
(sender As ObjectAs EventArgsHandles MyBase.Load
        ListBoxFill
()

 
   End Sub

    Private Sub Button1_Click
(sender As ObjectAs EventArgsHandles Button1.Click
        Dim op 
As New OpenFileDialog
        op
.Filter "PDF files (*.pdf)|*.pdf"
 
       If op.ShowDialog Windows.Forms.DialogResult.OK Then
            Dim data 
As Byte() = IO.File.ReadAllBytes(op.FileName)
 
           Dim sql As String "INSERT INTO table_1 (pdfname, pdfdata) VALUES (@pdfname, @pdfdata)"
 
           Dim comm As New SqlCommand(sqlcon)
 
           comm.Parameters.AddWithValue("@pdfname"IO.Path.GetFileName(op.FileName))
 
           comm.Parameters.AddWithValue("@pdfdata"data)

 
           con.Open()

 
           comm.ExecuteNonQuery()


 
           con.Close()


 
           ListBoxFill()

 
       End If
 
    

    End Sub

    Private Sub Button2_Click
(sender As ObjectAs EventArgsHandles Button2.Click
        If Me
.ListBox1.SelectedValue Is Nothing Then
            Exit Sub

        End 
If



 
       Dim sql As String "SELECT pdfname,pdfdata FROM table_1 WHERE id = " Me.ListBox1.SelectedValue
        Dim da1 
As New SqlDataAdapter(sqlcon)

 
       If da.Fill(dt) > 0 Then
            Dim row 
As DataRow dt.Rows(0)
 
           Dim tmpPath As String IO.Path.GetTempPath
            Dim fileName 
As String tmpPath "\" & row("pdfname")
            IO.File.WriteAllBytes(fileName, row("
pdfdata"))
            Process.Start(fileName)

        End If
    End Sub
   
End Class 
الرد }}}
تم الشكر بواسطة:


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  [سؤال] اين الخطا من فضلكم safalo 2 2,003 15-05-17, 11:57 PM
آخر رد: safalo
  مساعدة من فضلكم fouadhdfouad 0 1,588 18-04-17, 11:56 PM
آخر رد: fouadhdfouad
  اين الخطا في هذا الكود عالم التقنية 4 2,281 27-02-17, 06:44 AM
آخر رد: عالم التقنية

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم