 |
|
ไม่ลงฐานข้อมูล ช่วยเปิดดูให้ทีนะคะ จะขอบคุนมากค่ะ |
|
 |
|
|
 |
 |
|
ค่ะ คือว่ามันไม่มีเออเรออ่ะค่ะ กรอกข้อมูลได้ตามปกติแต่ข้อมูลไม่ลงฐานข้อมูลน่ะค่ะ
//เช็คค่าในฐานข้อมูลว่า ถ้าเพิ่มข้อมูลไปใหม่แล้ว มี series ,model, sfx เหมือนกัน ให้ เพิ่ม z ,y, x?.. ต่อท้ายฟิลดิ์ sfx เพื่อที่จะให้ค่าแตกต่งกัน//
If (Request("savetypenew") ="บันทึก" ) then
If (Request("nmtypenew1") <> "") and (Request("nmtypenew2") <> "") and (Request("nmtypenew3") <> "") then
If (len(Request("nmtypenew1")) >= 12) and (len(Request("nmtypenew2")) >= 2) and (len(Request("nmtypenew3")) >= 1) then
// สร้าง array เก็บ ค่า
Cha = array
("Z","Y","X","W","V","U","T","S","R","Q","P","O","N","M","L","K","J","I","H","G","F","E","D","C","B","A")
//เชคก่อนว่ามี series ,model, sfx เหมือนกันไหม//
sql = ""
sql = sql &"select count(MMT_MOD_SFX) as AMOUNT_SFX,count(MMT_SRS_CD) as AMOUNT_SRS,count(MMT_MOD_CD) as AMOUNT_MOD"
sql = sql &" from DSP_MOD_MST"
sql = sql &" where MMT_MOD_SFX = '"&Request("nmtypenew2")&"'"
sql = sql &" and MMT_SRS_CD= '"&Request("codetypenew1")&"'"
sql = sql &" and MMT_MOD_CD = '"&Request("nmtypenew1")&"'"
set rs = conn.execute(sql)
if not rs.eof then
Totalrecord = rs("AMOUNT_SFX") //เอาจำนวน เรคคอร์ดเก็บไว้ในตัวแปรเพื่อวนลูป//
for i = 0 to Cint(Totalrecord)-1
sql = ""
sql = "Select * From DSP_MOD_MST"
sql = sql & " Where MMT_SRS_CD = '" &Request("codetypenew1")& "' and"
sql = sql & " MMT_MOD_CD = '" &Request("nmtypenew1")& "' and"
sql = sql & " MMT_MOD_SFX = '" &Request("nmtypenew2")& "' and"
sql = sql & " MMT_FR_DT <= '"&DateNow&"' "
set rs = conn.execute(sql)
do while not rs.eof
rs.movenext
loop
//ถ้าซ้ำให้ insert แล้วเพิ่ม z ในฟิลดิ์ MMT_MOD_SFX ค่า Request("nmtypenew2")&Cha(i)//
sql = ""
sql = "Insert Into DSP_MOD_MST"
??.
??.
sql = sql & " MMT_MOD_SFX,"
sql = sql & " Values ('"&Request("codetypenew1")&"' , "
??.
??.
sql = sql & " '"&Request("nmtypenew2")&Cha(i)&"' , "
end if
next
else
ถ้าค่าไม่ซ้ำให้ insert ธรรมดา ไม่ต้องเพิ่ม z ต่อท้าย
Tag : - - - -
|
|
 |
 |
 |
 |
Date :
7 ต.ค. 2549 11:46:43 |
By :
isis |
View :
1999 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (ASP)
<% Option Explicit %>
<html>
<head>
<title>ThaiCreate.Com ASP & Microsoft Access Tutorial</title>
</head>
<body>
<%
Dim Conn,strSQL,objExec
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("mydatabase.mdb"),"" , ""
strSQL = ""
strSQL = strSQL &"INSERT INTO customer "
strSQL = strSQL &"(CustomerID,Name,Email,CountryCode,Budget,Used) "
strSQL = strSQL &"VALUES "
strSQL = strSQL &"('"&Request.Form("txtCustomerID")&"','"&Request.Form("txtName")&"', '"&Request.Form("txtEmail")&"' "
strSQL = strSQL &",'"&Request.Form("txtCountryCode")&"','"&Request.Form("txtBudget")&"', '"&Request.Form("txtUsed")&"') "
Set objExec = Conn.Execute(strSQL)
If Err.Number = 0 Then
Response.write("Save Done.")
Else
Response.write("Error Save ["&strSQL&"] ("&Err.Description&")")
End If
Conn.Close()
Set objExec = Nothing
Set Conn = Nothing
%>
</body>
</html>
Go to : ASP Microsoft Access Add/Insert Record
|
 |
 |
 |
 |
Date :
2011-09-25 08:36:31 |
By :
thaicreate |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|