|
|
|
ขอโค้ดการ Insert รูปภาพลงฐานข้อมูลแบบไม่ให้มันลบของเดิมทิ้งไปน่ะค่ะ |
|
|
|
|
|
|
|
ทำโปรเจคที่มีการ insert รูปภาพลงฐานข้อมูล แต่มีปัญหาอยู่ว่าถ้ารูปใหม่ที่เพิ่มเข้าไปชื่อมันซ้ำกับรูปเดิมที่มีในฐานข้อมูลมันจะบันทึกแทนที่รูปเดิมแล้วรูปเดิมก็หายไป มีคนแนะนำให้ใช้ auto id แต่ก็ทำไม่เป็นไม่รู้จะเขียนโค้ดออกมายังไง คิดไม่ออกเลยค่ะ ท่านผู้รู้ช่วยแนะนำด้วยนะคะ ขอโค้ดคร่าวๆก็ได้ค่ะ ใช้ vb2005 กับ access 2003 (vb.net ค่ะ)
จากโค้ดข้างล่างต้องเพิ่มเติมหรือแก้ไขโค้ดตรงไหนอีกหรอคะ
If IsUpload = True Then
Dim smartID As String = IDcard.Text
Dim nameIntellect As String = explore.Text
Dim bID As String = NBranch.Text
Dim OName As String = nameE.Text
Dim OAge As String = age.Text
Dim OAddress As String = no.Text + " " + mu.Text + " " + road.Text + " " + tam.Text + " " + umper.Text + " " + province.Text
Dim telephone As String = tel.Text
Dim owner As String = InOwner.Text
Dim intell As String = tobeIntell.Text
Dim dates As String = day.Text + " " + month.Text + " 2554 "
Dim steps As String = step9.Text
Dim CID As String = Session("UIN")
Dim Pic1 As String = NumPic(0)
Dim Pic2 As String = NumPic(1)
Dim Pic3 As String = NumPic(2)
Dim Pic4 As String = NumPic(3)
Dim Pic5 As String = NumPic(4)
Dim Pic6 As String = NumPic(5)
Dim Pic7 As String = NumPic(6)
Dim strcon1 As String
Dim sqlItem1 As String
strcon1 = "provider=microsoft.jet.oledb.4.0;data source=" & Server.MapPath("app_data\MukccExplore.mdb")
sqlItem1 = "select smartID from originator where smartID ='" & smartID & "' "
Dim conn As New OleDbConnection(strcon1)
conn.Open()
Dim com1 As New OleDbCommand(sqlItem1, conn)
Dim currentname As String
currentname = CStr(com1.ExecuteScalar)
conn.Close()
If currentname = "" Then
Dim develops As String
Dim devDetail As String
If dev.Text = 2 Then
develops = ""
devDetail = det3.Text
Else
develops = ""
devDetail = ""
End If
Dim strcon As String
Dim sqlItem As String
strcon = "provider=microsoft.jet.oledb.4.0;data source=" & Server.MapPath("app_data\MukccExplore.mdb")
sqlItem = "insert into originator (smartID,nameIntellect,bID,OName,OAge,OAddress,telephone,owner,develops,devDetail,intell,dates,steps,CID,IntellPic,pic1,pic2,pic3,pic4,pic5,pic6)"
sqlItem &= " values('" & smartID & "' , "
sqlItem &= "'" & nameIntellect & "' ,"
sqlItem &= "'" & bID & "' ,"
sqlItem &= "'" & OName & "' ,"
sqlItem &= "'" & OAge & "' ,"
sqlItem &= "'" & OAddress & "' ,"
sqlItem &= "'" & telephone & "' ,"
sqlItem &= "'" & owner & "' ,"
sqlItem &= "'" & develops & "' ,"
sqlItem &= "'" & devDetail & "' ,"
sqlItem &= "'" & intell & "' ,"
sqlItem &= "'" & dates & "' ,"
sqlItem &= "'" & steps & "' ,"
sqlItem &= "'" & CID & "' ,"
sqlItem &= "'" & Pic1 & "' ,"
sqlItem &= "'" & Pic2 & "' ,"
sqlItem &= "'" & Pic3 & "' ,"
sqlItem &= "'" & Pic4 & "' ,"
sqlItem &= "'" & Pic5 & "' ,"
sqlItem &= "'" & Pic6 & "' ,"
sqlItem &= "'" & Pic7 & "' )"
Dim con As New OleDbConnection(strcon)
con.Open()
Dim com As New OleDbCommand(sqlItem, con)
com.ExecuteNonQuery()
Tag : .NET, Ms Access, VBScript, Web (ASP.NET), VB.NET, VS 2005 (.NET 2.x)
|
ประวัติการแก้ไข 2011-09-23 13:39:45 2011-09-23 13:48:33 2011-09-23 13:51:04
|
|
|
|
|
Date :
2011-09-23 13:33:12 |
By :
oommiez |
View :
977 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ช่วยแนะนำด้วยค่ะ
|
ประวัติการแก้ไข 2011-09-23 13:50:42
|
|
|
|
Date :
2011-09-23 13:36:33 |
By :
oommiez |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|