الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

الصورة ما تتخزن مع ان الكود صح

بدأه lana2008 في 15 يونيو 2008 · 3 رد · 921 مشاهدة · في ADO.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

هلا انا عندي قاعدة بيانات فيها حقل يتعامل مع الصور من خلا StoredProcedure اضيف واحدث على table

المشكلة ان الكود صح في الفجوالبيسك ولايعطي اي خطاء بس ما بعرف شو الي بيصير لا التحديث يحدث الصورة ولا الاضافة بضيف الصورة

هذا كود الاضافة

'''' <summary>
    '''' This Method For Add Emloyee
    '''' </summary>
    Public Function Insert_Employee(ByVal Employee_ID_1 As Integer, ByVal Employee_Name_E As String, ByVal Employee_Name_A As String, ByVal Department As String, ByVal Resigned As String, ByVal Date_Of_Resignation As Date, ByVal photo As System.Drawing.Image, ByVal Birth_Day As Date, ByVal Jobtitle As String, ByVal Date_Of_Appointment As Date, ByVal Nationality As String, ByVal Bank As String, ByVal Bank_Account_Number As Integer, ByVal Bank_Branch As String, ByVal Mobile As Integer) As String
        conn.ConnectionString = con
        Dim m As New IO.MemoryStream()
        Dim cmd2 As New SqlCommand
        conn.Open()
        cmd2.CommandType = CommandType.StoredProcedure
        cmd2.Connection = conn
        cmd2.CommandText = "Insert_Employee_1"
        ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        '' 1
        cmd2.Parameters.Add("@Employee_ID_1", SqlDbType.Int, 4).Value = Employee_ID_1
        '' 2
        cmd2.Parameters.Add("@Employee_Name_E_2", SqlDbType.NVarChar, 50).Value = Employee_Name_E
        '' 3
        cmd2.Parameters.Add("@Employee_Name_A_3", SqlDbType.NVarChar, 50).Value = Employee_Name_A
        '' 4
        cmd2.Parameters.Add("@Department_4", SqlDbType.NVarChar, 50).Value = Department
        '' 5
        cmd2.Parameters.Add("@Resigned_5", SqlDbType.NVarChar, 50).Value = Resigned
        '' 6
        cmd2.Parameters.Add("@Date_Of_Resignation_6", SqlDbType.DateTime, 8).Value = Date_Of_Resignation
        '' 7
        cmd2.Parameters.Add("@Photo_7", SqlDbType.Image, 16).Value = photo
        photo.Save(m, System.Drawing.Imaging.ImageFormat.Jpeg)
        cmd2.Parameters("@Photo_7").Value = m.GetBuffer
        '' 8
        cmd2.Parameters.Add("@Birth_Day_8", SqlDbType.DateTime, 8).Value = Birth_Day
        '' 9
        cmd2.Parameters.Add("@Jobtitle_9", SqlDbType.NVarChar, 50).Value = Jobtitle
        '' 10
        cmd2.Parameters.Add("@Date_Of_Appointment_10", SqlDbType.DateTime, 8).Value = Date_Of_Appointment
        '' 11
        cmd2.Parameters.Add("@Nationality_11", SqlDbType.NVarChar, 50).Value = Nationality
        '' 12
        cmd2.Parameters.Add("@Bank_12", SqlDbType.NVarChar, 50).Value = Bank
        '' 13
        cmd2.Parameters.Add("@Bank_Account_Number_13", SqlDbType.Int, 4).Value = Bank_Account_Number
        '' 14
        cmd2.Parameters.Add("@Bank_Branch_14", SqlDbType.NVarChar, 50).Value = Bank_Branch
        '' 15
        cmd2.Parameters.Add("@Mobile_15", SqlDbType.Int, 4).Value = Mobile
        ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        cmd2.ExecuteNonQuery()
        conn.Close()
    End Function

وهذا كود التحديث

  Public Function Update_Employee(ByVal Employee_ID_1 As Integer, ByVal Employee_Name_E As String, ByVal Employee_Name_A As String, ByVal Department As String, ByVal Resigned As String, ByVal Date_Of_Resignation As Date, ByVal photo As System.Drawing.Image, ByVal Birth_Day As Date, ByVal Jobtitle As String, ByVal Date_Of_Appointment As Date, ByVal Nationality As String, ByVal Bank As String, ByVal Bank_Account_Number As Integer, ByVal Bank_Branch As String, ByVal Mobile As Integer) As String
        conn.ConnectionString = con
        Dim m As New IO.MemoryStream()
        Dim cmd2 As New SqlCommand
        conn.Open()
        cmd2.CommandType = CommandType.StoredProcedure
        cmd2.CommandText = "Update_Employee_1"
        cmd2.Connection = conn
        ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        '' 1
        cmd2.Parameters.Add("@Employee_ID_1", SqlDbType.Int, 4).Value = Employee_ID_1
        '' 2
        cmd2.Parameters.Add("@Employee_ID_2", SqlDbType.NVarChar, 4).Value = Employee_ID_1
        '' 3
        cmd2.Parameters.Add("@Employee_Name_E_3", SqlDbType.NVarChar, 50).Value = Employee_Name_E
        '' 4
        cmd2.Parameters.Add("@Employee_Name_A_4", SqlDbType.NVarChar, 50).Value = Employee_Name_A
        '' 5
        cmd2.Parameters.Add("@Department_5", SqlDbType.NVarChar, 50).Value = Department
        '' 6
        cmd2.Parameters.Add("@Resigned_6", SqlDbType.NVarChar, 50).Value = Resigned
        '' 7
        cmd2.Parameters.Add("@Date_Of_Resignation_7", SqlDbType.DateTime, 8).Value = Date_Of_Resignation
        '' 8
        cmd2.Parameters.Add("@Photo_8", SqlDbType.Image, 16)
        cmd2.Parameters("@Photo_8").Value = photo
        photo.Save(m, System.Drawing.Imaging.ImageFormat.Jpeg)
        cmd2.Parameters("@Photo_8").Value = m.GetBuffer
        '' 9
        cmd2.Parameters.Add("@Birth_Day_9", SqlDbType.DateTime, 8).Value = Birth_Day
        '' 10
        cmd2.Parameters.Add("@Jobtitle_10", SqlDbType.NVarChar, 50).Value = Jobtitle
        '' 11
        cmd2.Parameters.Add("@Date_Of_Appointment_11", SqlDbType.DateTime, 8).Value = Date_Of_Appointment
        '' 12
        cmd2.Parameters.Add("@Nationality_12", SqlDbType.NVarChar, 50).Value = Nationality
        '' 13
        cmd2.Parameters.Add("@Bank_13", SqlDbType.NVarChar, 50).Value = Bank
        '' 14
        cmd2.Parameters.Add("@Bank_Account_Number_14", SqlDbType.Int, 4).Value = Bank_Account_Number
        '' 15
        cmd2.Parameters.Add("@Bank_Branch_15", SqlDbType.NVarChar, 50).Value = Bank_Branch
        '' 16
        cmd2.Parameters.Add("@Mobile_16", SqlDbType.Int, 4).Value = Mobile
        ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        cmd2.ExecuteNonQuery()
        conn.Close()

وانو كل البياتات تنضاف عادي على الداتابيس بس الصورة ولا في اي خطاء

ياريت لو واحد يحكيلي الخطاء وين وشكررررررررر

تم تعديل هذه المشاركة بواسطة lana2008 في 15 يونيو 2008 في 11:17

#2

ولا جواب يعني الكود خطاء

#3

Hello...

I UnderStode that you wanna upload "image" from the client to the server

okay::::

1St Thing that you have to understand that there are two ways to do that:

1) Convert the image as bytes Value and send it to the database in the server

2) just Send that name of picture to the database and upload the image to the folder in the server which is the most helpfull way to do

** i prefer the 2nd way cause we dont know the size of pic (byte size) and if the picture binding with a Virus that we dont wanna be inside our database!!!!!!!!!!

So,i advise you to do the 2nd way

okay..if you gonna looking to the big websites companies ..you will understand that they do the 2nd way..which save the size of the database and keep it away from all hackers(which they like the 1st way to hack to server)

lets explain the 2nd way to you:

lets say that we have a table named "customer" which include the "picture"of customers

all we need to do is know the fullname of picture such as " me.gif"..,then

only save the "me.gif" to the our database then we will upload the picture from the client to the Folder in the server in the specific Path like "Images"

so when we wanna show the image from the server we use " server.mappath("images")"

which return the Virtual path of "image" Folder.. then Give the name of pic from the database ...its not hard its gonna be like:

dim picture as string=server.mappath("\images") & "name_of_pic

the if we have imagecontrol named"img"

img.fromfile(picture)

And Hola..That's it

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…