below the codes works. it save files to database whenever user click on it.
but what i want is user uploaded a file to database, and when he uploads again, the uploaded file will replace the previous file leaving the database only have a single file all times. instead of keep on making a new row to store files.
help to correct my code...thanks all.....
Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnUpload.Click
If FileExtensionIsApproved(fUpload.HasFile) Then
Dim test = fUpload.PostedFile.FileName
Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ToString)
Dim da As New SqlDataAdapter("Select * From files", con)
Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da)
Dim ds As New DataSet()
da.MissingSchemaAction = MissingSchemaAction.AddWithKey
Dim fs As New FileStream(test, FileMode.OpenOrCreate, FileAccess.Read)
Dim MyData(fs.Length) As Byte
fs.Read(MyData, 0, fs.Length)
Dim myRow As DataRow
myRow = ds.Tables("Mydata").NewRow()
View Complete Post