找不到文件'Blue hills.jpg'。 [英] Could not find file 'Blue hills.jpg'.
本文介绍了找不到文件'Blue hills.jpg'。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码:
私人 Sub ReadImageToBytes( ByVal sPath As String , ByVal sid As 字符串)
Dim fInfo 作为 新 FileInfo(sPath)
Dim len As < span class =code-keyword>长
len = fInfo.Length
' 'Dim myConnection As New SqlConnection(server = ITPROGRAMMER; uid = sa; Password = ssm_123; database = buildersid)
Dim connString As String = server = ITPROGRAMMER; uid = sa; Password = ssm_123; database = buildersid
使用 stream 作为 < span class =code-keyword> New FileStream(sPath.Trim(),FileMode.Open)
Dim imgData ()作为 字节 = 新 Byte (Convert.ToInt32(len - 1 )){}
stream.Read(imgData,< span class =code-digit> 0 ,len)
使用 con As 新 SqlConnection(connString)
使用 cmd As 新 SqlCommand()
con.Open()
cmd.Connection = con
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = staffupdate
cmd。 Parameters.AddWithValue( @ emp_id,sid)
cmd.Parameters.AddWithValue(< span class =code-string> @ image_photo,imgData)
cmd.Parameters.AddWithValue( @ image_path,sPath)
cmd.ExecuteNonQuery()
con.Close()
' '返回真实
结束 使用
结束 使用
结束 使用
' Catch ex作为SqlException
' MessageBox.Show(ex.ToString)
' 返回错误
' Catch ex As Exception
' MessageBox.Show(ex.ToString)
' < span class =code-comment>返回False
< span class =code-comment>' 结束尝试
结束 Sub
我在这段代码中做错了什么。 ???有人告诉我.... plzz
解决方案
尝试提供你想要的文件的完整路径blue hills.jpg而不仅仅是文件名。
My Code:
Private Sub ReadImageToBytes(ByVal sPath As String, ByVal sid As String)
Dim fInfo As New FileInfo(sPath)
Dim len As Long
len = fInfo.Length
''Dim myConnection As New SqlConnection("server=ITPROGRAMMER;uid=sa;Password=ssm_123;database=buildersid")
Dim connString As String = "server=ITPROGRAMMER;uid=sa;Password=ssm_123;database=buildersid"
Using stream As New FileStream(sPath.Trim(), FileMode.Open)
Dim imgData() As Byte = New Byte(Convert.ToInt32(len - 1)) {}
stream.Read(imgData, 0, len)
Using con As New SqlConnection(connString)
Using cmd As New SqlCommand()
con.Open()
cmd.Connection = con
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "staffupdate"
cmd.Parameters.AddWithValue("@emp_id", sid)
cmd.Parameters.AddWithValue("@image_photo", imgData)
cmd.Parameters.AddWithValue("@image_path", sPath)
cmd.ExecuteNonQuery()
con.Close()
'' Return True
End Using
End Using
End Using
'Catch ex As SqlException
' MessageBox.Show(ex.ToString)
' Return False
'Catch ex As Exception
' MessageBox.Show(ex.ToString)
' Return False
'End Try
End Sub
what i did wrong in this code.???? anyone tell to me....plzz
解决方案
Try supplying the full path to the file you want "blue hills.jpg" instead of just the file name.
这篇关于找不到文件'Blue hills.jpg'。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文