我找不出正確的代碼來保存數據庫中的文件名字符串。我的代碼如下:無法保存數據庫中的文件上傳文件名
FileUpload1.SaveAs(Server.MapPath("pimages/" + FileUpload1.FileName))
MsgBox(FileUpload1.FileName)
Dim newUsr As MembershipUser = Membership.GetUser()
Dim newUserId As Guid = CType(newUsr.ProviderUserKey, Guid)
' Insert a new record into UserProfiles
Dim connectionString As String = ConfigurationManager.ConnectionStrings("LocalSqlServer").ConnectionString
Dim insertSql As String = "UPDATE UserProfiles Set (Pic = @Pic) Where (UserId = @UserID)"
Using myConnection As New SqlConnection(connectionString)
myConnection.Open()
Dim myCommand As New SqlCommand(insertSql, myConnection)
myCommand.Parameters.AddWithValue("@UserId", newUserId)
myCommand.Parameters.AddWithValue("@Pic", FileUpload1.FileName)
myCommand.ExecuteNonQuery()
myConnection.Close()
End Using
有人可以糾正這個請嗎?
它給你什麼錯誤/例外? –