Try If (con.State = ConnectionState.Closed) Then con.Open() End If Dim curdir As String = AppDomain.CurrentDomain.SetupInformation.ApplicationBase If ID <> 0 Then If (Not txtFileUploadPath.Text = Nothing And Not String.IsNullOrEmpty(txtFileUploadPath.Text)) Then FileIO.FileSystem.DeleteFile(curdir & "Excel\" & Subject) ' objdal.ExamSchedule = CmboSubject.Text & "_" & CmboSub_Subject.Text & "." & txtFileUploadPath.Text.Split(New Char(), ("."))(1).ToString() objdal.ExamSchedule = TxtSubject.Text & "." & txtFileUploadPath.Text.Split(New Char(), ("."))(1).ToString() FileCopy(txtFileUploadPath.Text, curdir & "Excel\" & objdal.ExamSchedule) Else objdal.ExamSchedule = "" End If objdal.ID = ID objdal.UpdateExamSchedule() Else Dim doc As String() Dim ext As String doc = txtFileUploadPath.Text.Split(New Char(), (".")) ext = doc(doc.Length - 1) If (Not txtFileUploadPath.Text = Nothing And Not String.IsNullOrEmpty(txtFileUploadPath.Text)) Then ' objdal.ExamSchedule = CmboSubject.Text & "_" & CmboSub_Subject.Text & "." & ext objdal.ExamSchedule = TxtSubject.Text & "." & ext FileCopy(txtFileUploadPath.Text, curdir & "Excel\" & objdal.ExamSchedule) Else objdal.ExamSchedule = "" End If Dim cmd As New OleDbCommand("insert into FileUpload(Sid,Sub_ID,CID,Sub_Cid,Subject,FileUpload)Values(" & CmboSubject.SelectedValue & "," & CmboSub_Subject.SelectedValue & "," & CmboCategory.SelectedValue & "," & CmboSubCategory.SelectedValue & ",@Subject,@image)", con) cmd.Parameters.AddWithValue("@Subject", Convert.ToString(TxtSubject.Text)) cmd.Parameters.AddWithValue("@image", txtFileUploadPath.Text) cmd.ExecuteNonQuery() MessageBox.Show("file Upload") cleartxt() con.Close() End If Catch ex As Exception MessageBox.Show(ex.ToString()) End Try
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)