|
 |
|
มีปัญหากับ Access ครับ พอกระบวนการเสร็จเรียบร้อยแล้ว ไฟล์ access.ldb ค้าง ไม่ยอมหาย |
|
 |
|
|
 |
 |
|
มีปัญหากับ Access ครับ พอกระบวนการเสร็จเรียบร้อยแล้ว ไฟล์ access.ldb มันยังค้างอยู่เลยครับ มันไม่ยอมหาย โค๊ตการทำงานประมาณนี้ครับ รบกวนช่วยหน่อยนะครับ
Code (VB.NET)
Dim FileIn As New FileInfo(Server.MapPath("STD.mdb"))
If FileIn.Exists Then
FileIn.Delete()
End If
Sub_CreateNewMDB(Server.MapPath("STD.mdb"), Jet4x)
' -------------------------------------------------------------------
Dim Cn As ADODB.Connection, Cat As ADOX.Catalog, objTable As ADOX.Table
Cn = New ADODB.Connection
Cat = New ADOX.Catalog
objTable = New ADOX.Table
Cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("STD.mdb"))
Cat.ActiveConnection = Cn
'เพิ่มชื่อตาราง
objTable.Name = "Survey"
'เพิ่มชื่อฟิลด์
objTable.Columns.Append("STUDENT_CODE") 'รหัสประจำตัวนิสิต
objTable.Columns.Append("STUDENT_NAME") 'ชื่อ-สกุล
objTable.Columns.Append("CITIZENID") 'รหัสประจำตัวประชาชน
objTable.Columns.Append("BAN_NUMBER") 'บ้านเลขที่
objTable.Columns.Append("MOO") 'หมู่
objTable.Columns.Append("ALLEYS") 'ซอย
objTable.Columns.Append("ROAD") 'ถนน
objTable.Columns.Append("BAN") 'บ้าน
objTable.Columns.Append("DISTRICT") 'ตำบล
objTable.Columns.Append("AMPUR") 'อำเภอ
objTable.Columns.Append("PROVINCE") 'จังหวัด
objTable.Columns.Append("POST") 'รหัสไปรษณยี์
objTable.Columns.Append("PHONE") 'เบอร์โทรศัพท์
objTable.Columns.Append("EMAIL") 'อีเมล์
objTable.Columns.Append("MAJOR") 'สาขา
objTable.Columns.Append("FACULTY") 'คณะ
objTable.Columns.Append("SURVEY_YEAR") 'ปีการศึกษา
objTable.Columns.Append("WORK_STATUS") 'สถานะการทำงาน
Cat.Tables.Append(objTable)
objTable = Nothing
Cat = Nothing
Cn.Close()
Cn = Nothing
'--------------------------------------------------------------------------
Dim MyConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("STD.mdb"))
MyConnection.Open()
Dim sql_string, Name As String
sql1 = " SELECT S_SURVEY.*, STUDENTMAIN.STUDENTCODE, "
sql1 &= " STUDENTMAIN.STUDENTNAME, STUDENTMAIN.STUDENTSURNAME, "
sql1 &= " PREFIXID.PREFIXNAME, STUDENTDETAIL.CITIZENID,FACULTY.FACULTYNAME, MAJOR.MAJORNAME "
sql1 &= " FROM S_SURVEY "
sql1 &= " INNER JOIN STUDENTMAIN ON STUDENTMAIN.STUDENTID = S_SURVEY.STUDENTID "
sql1 &= " INNER JOIN PREFIXID ON STUDENTMAIN.PREFIXID = PREFIXID.PREFIXID "
sql1 &= " INNER JOIN STUDENTDETAIL ON STUDENTMAIN.STUDENTID = STUDENTDETAIL.STUDENTID "
sql1 &= " INNER JOIN FACULTY ON STUDENTMAIN.FACULTYID = FACULTY.FACULTYID"
sql1 &= " INNER JOIN MAJOR ON STUDENTMAIN.MAJORID = MAJOR.MAJORID "
sql1 &= " where SURVEY_YEAR = '" & Me.DropDownList1.Text & "' "
Cmd1 = New OracleCommand(sql1, Conn)
dtReader1 = Cmd1.ExecuteReader()
While dtReader1.Read()
Name = dtReader1.Item("PREFIXNAME") & "" & dtReader1.Item("STUDENTNAME") & " " & dtReader1.Item("STUDENTSURNAME")
sql_string = " INSERT INTO Survey "
sql_string &= " (STUDENT_CODE,STUDENT_NAME, "
sql_string &= " CITIZENID,"
sql_string &= " BAN_NUMBER,MOO, "
sql_string &= " ALLEYS,ROAD, "
sql_string &= " BAN,DISTRICT, "
sql_string &= " AMPUR,PROVINCE, "
sql_string &= " POST,PHONE, "
sql_string &= " EMAIL, "
sql_string &= " MAJOR, "
sql_string &= " FACULTY, "
sql_string &= " SURVEY_YEAR, "
sql_string &= " WORK_STATUS) "
sql_string &= " VALUES "
sql_string &= " ('" & dtReader1.Item("STUDENTCODE") & "','" & Name & "', "
sql_string &= " '" & dtReader1.Item("CITIZENID") & "',"
sql_string &= " '" & dtReader1.Item("SURVEY_NUMBER") & "','" & dtReader1.Item("SURVEY_MOO") & "', "
sql_string &= " '" & dtReader1.Item("SURVEY_ALLEYS") & "','" & dtReader1.Item("SURVEY_ROAD") & "', "
sql_string &= " '" & dtReader1.Item("SURVEY_HOME") & "','" & dtReader1.Item("SURVEY_DISTRICT") & "', "
sql_string &= " '" & dtReader1.Item("SURVEY_ZONE") & "','" & dtReader1.Item("SURVEY_PROVINCE") & "', "
sql_string &= " '" & dtReader1.Item("SURVEY_POSTALCODE") & "','" & dtReader1.Item("SURVEY_PHONE") & "', "
sql_string &= " '" & dtReader1.Item("SURVEY_EMAIL") & "', "
sql_string &= " '" & dtReader1.Item("MAJORNAME") & "', "
sql_string &= " '" & dtReader1.Item("FACULTYNAME") & "', "
sql_string &= " '" & dtReader1.Item("SURVEY_YEAR") & "', "
sql_string &= " '" & dtReader1.Item("SURVEY_CHECK_WORK") & "')"
Dim MyCommand As New OleDbCommand(sql_string, MyConnection)
MyCommand.ExecuteNonQuery()
End While
dtReader.Close()
dtReader1.Close()
Cn.Close()
MyConnection.Close()
Tag : .NET, Ms Access, Oracle, Web (ASP.NET), VS 2010 (.NET 4.x)

|
|
 |
 |
 |
 |
Date :
2012-05-06 17:43:56 |
By :
mylovekukkai |
View :
1122 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
การปิด Connection ไม่สมบูรณ์หรือเปล่าครับ 
|
 |
 |
 |
 |
Date :
2012-05-06 18:11:58 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำไมคุณจะต้อง เปิด-ปิด 2 ครั้งครับ
|
 |
 |
 |
 |
Date :
2012-05-07 06:37:38 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|