asp寫入資料庫access
『壹』 asp如何寫入Access(高手幫忙)
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file = "tuzh_pri.asp"-->
<!--#include file ="../connadmin.asp"-->
<%if request.QueryString("action")="modi" and trim(request.QueryString("id"))<>"" then
dim modi
modi="y"
set rsok=server.createobject("adodb.recordset")
sqlok="select * from com where id="&cint(trim(request.QueryString("id")))
rsok.open sqlok,conn,1,3
rsok.addnew
doid=rsok("id")
title= rsok("title")
content= rsok("content")
kind_id= rsok("yiid")
rsok.update
rsok.close
set rsok=nothing
end if%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="../img/css.css">
<title></title>
<title>無標題文檔</title>
<SCRIPT language=JavaScript>
function checklogin() {
if (document.form1.kind.value=="") {
alert("請選擇類別!");
form1.kind.focus();
return false;
}
if (document.form1.txttitle.value=="") {
alert("請輸入標題!");
form1.txttitle.focus();
return false;
}
return true;
}
</SCRIPT>
</head>
<%
set rs=server.createobject("adodb.recordset")
sql="select * from com_kind"
rs.open sql,conn,1,1
dim lm1
lm1=""
do while not rs.eof
if modi="y" and kind_id=rs("yiid") then
lm1=lm1&"<option value='" & rs("yiid") & "' selected>" & rs("yiname")&"</option>"
else
lm1=lm1&"<option value='" & rs("yiid") & "'>" & rs("yiname")&"</option>"
end if
rs.movenext
loop
rs.close%>
『貳』 asp添加數據進access資料庫
假設你單選按鈕的名稱是 "check" ,值分別就是1,2,3哈
check=request.form("check")
sql="select * from [tongji]"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,3,3
rs.addnew
if check="1" then
rs("yjs")="yes"
elseif check="2" then
rs("yns")="yes"
else
rs("yys")="yes"
end if
rs.update
rs.close
set rs=nothing
『叄』 asp如何實現表單上傳圖片後存入access資料庫
asp中表單上傳圖片後會解析成二進制byte數組保存到access資料庫。
1、上傳圖片:
OpenFileDialog open = new OpenFileDialog();
// image filters
open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
if (open.ShowDialog() == DialogResult.OK)
{
// display image in picture box
pictureBox1.Image = new Bitmap(open.FileName);
// image file path
textBox1.Text = open.FileName;
}
2、保存圖片信息到acess資料庫。
C#實現,保存核心代碼:
var pic = File.ReadAllBytes(yourFileName);
using(OleDbConnection con = new OleDbConnection(constr))
using(OleDbCommand cmd = new OleDbCommand("Insert Into DML_Books_List(ID, [Image]) values (@id, @image)", con))
{
con.Open();
cmd.Parameters.AddWithValue("@id", TextBox1.Text);
cmd.Parameters.AddWithValue("@image", pic);
cmd.ExecuteNonQuery();
}
『肆』 asp將本地的excel表格數據寫入網站的access資料庫
不是那麼復雜吧,使用ADO首先打開 本地的excel表格 讀取數據,然後打開 網站的access資料庫,寫入數據就可以了呀。
ADO 對象支持打開 Excel 表格,也支持打開 Access 資料庫以及其他資料庫。
『伍』 ASP讀取選擇文件夾的所有文件名寫入Access資料庫
循環讀取文件夾文件和子文件夾,可通過FSO組件完成。
FunctionBianli(path)
SetFso=server.createobject("scripting.filesystemobject")
OnErrorResumeNext
SetObjfolder=fso.getfolder(path)
SetObjsubfolders=objfolder.subfoldersNowpath=path+""+Objsubfolder.name
Response.writeNowpath
SetObjfiles=objsubfolder.files
ForEachObjfileInObjfiles
Response.write"<br>---"
Response.writeObjfile.name
Next
Response.write"<p>"
Bianli(nowpath)'遞歸
Next
SetObjfolder=nothing
SetObjsubfolders=nothing
SetFso=nothing
EndFunction
寫入資料庫
DBPath="ques.mdb"'ACCESS資料庫的文件名,請使用相對於網站根目錄的的絕對路徑
ConnStr="Provider=Microsoft.Jet.OLEDB.4.0;DataSource="&Server.MapPath(DBPath)
FunctionQuestionInMdb(byvalQuesTion)
SetConn55=server.createobject("adodb.connection")'連接組件
Conn55.openConnStr'連接資料庫
Setrs=server.createobject("adodb.recordset")
sql="selecttop1*fromqa"
rs.opensql,Conn55,1,3
rs.addnew
rs("QuesTion")=QuesTion
QuestionInMdb=rs("id")
rs.close
Setrs=Nothing
Conn55.close
SetConn55=Nothing
EndFunction
『陸』 在ASP中怎樣把表單中的數據存入ACCESS資料庫中
提交表單數據到資料庫處理程序,使用add增加到資料庫,參考以下代碼:
<!--#include file="conn.asp"-->'連接資料庫的程序
<%
Set Rs=server.createobject("ADODB.Recordset")
Sql="select * from user"
Rs.open Sql,conn,1,3
Rs.Addnew
Rs("username") = trim(request.Form("username"))
Rs("password") = trim(request.Form("password"))
RS("age") = trim(request.Form("age"))
Rs.update
Rs.close
%>
『柒』 ASP表單寫入ACCESS資料庫代碼。
你資料庫有沒有自動編號欄位?
如果有,你的sql語句錯誤
select user,qq,email,content,data from main
你只是選取了user,qq,email,content,data 這幾個欄位
而沒有選取自動編號欄位
『捌』 asp如何將當前時間寫入access資料庫中
我用過的方法:
1、在資料庫里定義一個保存當前時間的欄位,不要和一些關鍵字同名(如time)。
2、設兩個變數來或取日期和時間,
如:date1
=
date(now)
time1
=
time(now)
shijian
=
date1
+
time1
3、把時間寫入資料庫
『玖』 asp在access資料庫中插入數據
1.字元串鏈接不要用
+
,用
&
。
2。請確定request的數據內容類型和書庫中欄位類型相同,也要確定不為空。
3。再不會弄就用記錄集添加
rs.open
sql,conn,3,3
rs.addnew
rs("id")=id
........
rs.update
rs.updatebatch
rs.close
set
rs=nothing
『拾』 asp寫入access資料庫亂碼,只有一個表亂碼
不是,應該是這樣做,按我說的你來查一下你的網站:第一:把每個頁面一個一個用記事本打開---文件---另存為---編碼(窗口中最下面的)---選擇UTF-8-----保存!如果這里是已經utf-8的話就好了,必須打開每頁看看,尤其是亂碼出來的頁面和全部分頁面!第二:把asp頁面文件里上部的字元編碼 gb2312改成utf-8,看看全部頁面是否這樣的!第三:conn,asp檢查一下,上面有沒有 Response.CharSet = "utf-8"
Session.CodePage=65001第四:第四不說了應該是上面問題,請查看!