asp表單新增data時無法至資料庫中

<%

strsql="insert into seqnum,tech,layer,Au,Density,Pt,Pd,Ag"

strsql=strsql&" FROM pldmes.t_wf_scrap_metal"

strsql=strsql&" WHERE seqnum='"+request("seqnum")+"'"

rstobj=server.createobject("adodb.recordset")

%>

請問這一小段需要補充什麼嗎?為何data無法新增至資料庫咧?

Update:

db:

<%

SET O7Conn=Server.CreateObject("ADODB.Connection")

O7Conn.open "dsn=oracle7;uid=pldmes;pwd=pmleds;database=pld"

%>

Update 2:

table:

t_wf_scrap_metal(主要table)

t_wf_scrap_metal_ck(稽核用的table)

新增:

一次新增一筆資料(seqnum,tech,layer,Au,Density,Pt,Pd,Ag)

欄位長度:

seqnum:number(3)

Tech:varchar2(9)

Layer:varchar2(4)

Au,Density,Pt,Pd,Ag:number

Update 3:

那如果是要"修改"呢

Update 4:

提供使用者挑選tech,然後調出這一個tech的所有資料讓使用者修改。

*儲存資料時要把修改前的資料複製一份至t_wf_scrap_metal_ck,並記錄下修改人及日期

Update 5:

這裡要如何修改,才能秀出dtat呢?大大們

Update 6:

strsql="select * from "& session("tablename")&" where tech like '"&tech&"%' and"&strsql &" group by seqnum"

3 Answers

Rating
  • Lv 6
    1 decade ago
    Favorite Answer

    SQL語法有很大的問題,請參閱此網站

    http://www.1keydata.com/tw/sql/sql.html

    其中的Insert into

    INSERT INTO Store_Information (store_name, Sales, Date)

    VALUES ('Los Angeles', 900, 'Jan-10-1999')

    strsql="insert into t_wf_scrap_metal( seqnum,tech,layer,Au,Density,Pt,Pd,Ag)"

    strsql=strsql&" Values (" & seqnum & ",' " & tech & " ',' " & Layer & "," & Density & "," & Pt & "," & Pd & "," & Ag & ")"

    數字不可以有字串',日期格式要小心使用,各種資料庫的日期格是要轉換正確

    SQL = "insert into t_wf_scrap_metal("

    SQL = SQL & " seqnum,"

    SQL = SQL & "tech,"

    SQL = SQL & "layer,"

    SQL = SQL & "Au,"

    SQL = SQL & "Density,"

    SQL = SQL & "Pt,"

    SQL = SQL & "Pd,"

    SQL = SQL & "Ag"

    SQL = SQL & ") Values ("

    SQL = SQL & seqnum & ","

    SQL = SQL & " ' " & tech & " ' ,"

    SQL = SQL & " ' " & Layer & " ',"

    SQL = SQL & Density & ","

    SQL = SQL & Pt & ","

    SQL = SQL & Pd & ","

    SQL = SQL & Ag & ")"

    Response.Write(SQL)

    以上是我比較喜歡的寫法,這樣比較容易檢查出哪個欄位錯誤或是哪個值給錯

    2008-07-22 22:46:53 補充:

    strsql="select * from "& session("tablename")&" where tech like '"&tech&"%' and"&strsql &" group by seqnum"

    你的Table名稱有需要使用Session嗎??

    tech是使用網頁來挑選就不需要使用Like來模糊查詢

    strsql = "select * from t_wf_scrap_metal"

    strsql = strsql & " where tech = '" & tech & "'"

    2008-07-22 22:46:57 補充:

    'strsql = strsql & " group by seqnum" <--這裏使用方式也不正確,是要用order by還是group by

    建議你買本SQL語法的專書詳細了解清楚,下苦功去學比較有成就啦

    Source(s): 網頁讀取資料庫
  • 1 decade ago

    這樣的問題實在太.....太基礎了。

    買本書,放在手邊看看。

    不要拿到程式就亂改,

    亂改,然後亂問。這樣是惡性循環,學不好東西的。

  • 1 decade ago

    你要 insert into 到那一個資料表? 似乎沒寫

Still have questions? Get your answers by asking now.