1、網頁製作——如何實現調用資料庫?
首先,頁面1中用表單提交數據你要查詢的數據
代碼參考:<form action="對應的servlet類" metohd="post" name="form1">
接著,建立一個selvet類,繼承HttpServlet,在selvet類的doPost()方法里寫入查詢資料庫的代碼,主要利用request來獲取頁面1中的參數,通過reponse來給頁面2傳輸資料庫查詢的結果
代碼參考:
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
String name=request.getParameter("name");
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection( "jdbc:oracle:thin:@localhost:test1", "test","stst");
stmt = conn.createStatement();
rs = stmt.executeQuery("select ename,empno,deptno from emp where empno like \'"+name+"');
reponse.setContentType("text/html;charset=GB2312");
PrintWriter out=response.getWritertr();
out.println("<html> <body>");
out.print("<table border>");
out.print("<tr><td colspan=8 align=center>用戶數據</td></tr>");
out.print("<tr>");
while(rs.next)
{
our.print("<tr>");
our.print("<td>"+rs.getString("ename")+</td>);
our.print("<td>"+rs.getString("emono")+</td>);
our.print("<td>"+rs.getString("depno")+</td>);
our.print("</tr>");
}
out.print("</tr>");
out.print("</table>");
out.print("</body> </html>");
out.close();
rs.close();
stmt.close();
con.close();
2、製作網頁的登陸登陸界面怎樣與資料庫里的內容連接全過程
你是使用的JSP嗎? 如果你是使用JSP的話,資料庫連接的步驟如下:
1.把JDBC驅動類裝載入Java虛擬回機中:
Class.forName("JDBC驅動類名答稱");
2.載入驅動,並與資料庫建立連接:
Connection conn=DriverManager.getConnection(資料庫連接字元串,資料庫用戶,資料庫密碼)
3.發送SQL語句:
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("SELECT a,b,c FROM TABLE");
4.處理結果 :
while(rs.nest()){
int x=rs.getint("a");
}
這就是連接資料庫,希望我的回答能讓你滿意
3、c#html 網頁設計 怎麼連接資料庫
SqlConnection xxx = new SqlConnection("Server=伺服器名稱;User ID=登錄名;Password=密碼;Initial catalog=庫名;");
string sql = "對資料庫的操作";
SqlCommand comm = new SqlCommand(sql, xxx);
xxx.Open();
SqlDataReader dd = comm.ExecuteReader();
dd.Close();
xxx.Close();
4、網頁設計中用戶登陸設計時怎樣與資料庫連接?
這樣:
一個資料庫,表名為login,假設為Access資料庫,內有name,pw兩個欄位。
一個登陸頁面:login.asp
一個檢驗頁面:check.asp
login.asp部分代碼(省略html代碼,只列部分關鍵代碼,不會的可發送消息給我):
<form method="post" action="info.asp">
<input type="type" name="name">
<input type="password" name="pw">
</form>
check.asp部分代碼:
<%
dim name,pw
name=trim(request("name"))
pw=trim(request("pw"))
if name="" or pw="" then
response.Write "<script language='javascript'>window.confirm('對不起,用戶名或密碼均不能為空!');</script>"
response.Write "<script language='javascript'>parent.window.history.go(-1);</script>"
else
set rs=server.CreateObject("adodb.recordset")
sql="select * from info where name='"&name&"' and pw='"&pw&"'"
rs.open sql,conn,1,1
if rs.recordcount=0 then
response.Write "<script language='javascript'>window.confirm('對不起,用戶名或密碼錯誤,請重新登陸!');</script>"
response.Write "<script language='javascript'>parent.window.history.go(-1);</script>"
else
response.Write "<script language='javascript'>alert('登陸成功!');</script>"
response.Write "location.href='admin.asp';" ''admin.asp為登陸成功後轉向的頁面
end if
end if
%>
5、如如何將網頁連接到資料庫?
一、要實現用戶輸入,肯定前台要是一個網頁,使用jsp,先建一個jsp網頁。

二、使用servlet,在jsp文件中,需要一個表單form把數據傳到servlet中,antion裡面寫servlet的地址,method裡面寫方法「get或者post」,一般刪除數據默認是「get」添加數據是「post」。

三、在servlet中來獲取頁面上的值,注意獲取的值是String類型的。 如果要用到int型,就想要強轉類型。

四、把數據插入到 對象的屬性中,使用set的方法。

五、調用add的方法,就可以把數據插入到後台。

六、具體的插入到資料庫的代碼要注意資料庫的鏈接。

6、網頁設計怎麼連接到資料庫?
<%Dim
connweb,
connstr
connstr
=
"provider=sqloledb;data
source=IP地址或機器名;uid=用戶名;pwd=登錄密碼;database=資料庫名;"
Set
connweb
=
server.createobject("adodb.connection")
connweb.open
connstr
%>
7、網站製作 靜態的HTML文件已經做好了,怎麼連接資料庫
access資料庫一般用ASP,下面是示例代碼:
asp連接access資料庫應用下面代碼
<%
set conn=Server.CreateObject("ADODB.Connection")
DBPath = Server.MapPath("board.mdb") 'Server.MapPath("board.mdb") 獲得資料庫文件board.mdb的絕對路徑
conn.Open "provider=microsoft.jet.oledb.4.0;data source="&dbpath
%>
首先在board.mdb資料庫里建立一張數據表board(id,title,content,subtime)個欄位數據類型自己思考,環境都建好了,下面我們就開始程序設計,無論網頁還是程序我建議用dw來做吧,我就是用它的
本例中涉及到的文件有
conn.asp資料庫鏈接文件
send.asp,發表留言界面頁
sendok.asp,留言錄庫操作程序文件
board.asp留言讀庫顯示頁面
文件的內容附件里有源文件大家可以下載察看
首先介紹asp一個很有效的特性就是伺服器端包含
<!--#i nclude file="conn.asp"-->
其中conn.asp就是被包含的文件,此包含可以出現在文件的任意位置
被包含的文件內容將完全被解釋成包含文件的內容,,重復的代碼也會大大降低。
conn.asp內容
<%
set conn=Server.CreateObject("ADODB.Connection")
DBPath = Server.MapPath("board.mdb")
conn.Open "provider=microsoft.jet.oledb.4.0;data source="&dbpath
%>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
send.asp內容
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; ch***t=gb2312">
<title>無標題文檔</title>
<style type="text/css">
<!--
.style1 {font-size: 18px}
-->
</style>
</head>
<body>
<table width="700" border="0" align="center">
<form name="form1" method="post" action="sendok.asp">
<tr>
<td><div align="center" class="style1">發布留言</div></td>
</tr>
<tr>
<td align="center">標題:
<input name="title" type="text" size="50"></td>
</tr>
<tr>
<td align="center">內容:
<textarea name="content" cols="50"></textarea></td>
</tr>
<tr>
<td align="center"><input type="submit" name="Submit" value="提交"></td>
</tr>
</form>
</table>
</body>
</html>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sendok.asp內容
<!--#i nclude file="conn.asp"-->
<%
title=request.form("title")
content=request.form("content")
subtime=now()
conn.execute("insert into board (title,content,subtime) values('"&title&"','"&content&"','"&subtime&"')")
%>
<script>
alert("留言成功!");
location.href="/board.asp";
</script>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
board.asp內容
<!--#i nclude file="conn.asp"-->
<style type="text/css">
<!--
.style2 {
font-size: 16px;
font-weight: bold;
}
-->
</style>
<table width="300" border="0" align="center">
<tr>
<td align="center"><span class="style2">留言板查看</span></td>
</tr>
</table>
<br>
<br>
<table width="200" border="0" align="center">
<tr>
<td align="center"><a href="/send.asp">發表留言</a></td>
</tr>
</table>
<br>
<br>
<%
set rs=conn.execute("select * from board order by id desc")
do while not rs.eof
%>
<table width="600" border="0" align="center" cellspacing="1" bgcolor="#999999">
<tr bgcolor="#FFFFFF">
<td width="447"><%=rs("title")%></td>
<td width="146"><%=rs("subtime")%></td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="2"><%=rs("content")%></td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="2"> </td>
</tr>
</table>
<%
rs.movenext
loop
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
8、如何將前端網頁與後台資料庫連接?
前端和後端之所以需要對接,是因為前端頁面只負責提供視圖沒有內容,而後端只提供內容,兩者所謂的對接,就是把後端的內容放在前端頁面預留出來的位置上。(雖然說是前端後端,但這一對接實際發生在伺服器端)。
所以伺服器端進行的活動如下:
接收用戶請求——》找到負責處理的程序——》處理程序找到要傳輸給用戶的前端頁面——》該前端頁面留出位置——》後端到資料庫取數據——》後端把數據放在前端留出來的位置上——》結合成真正用戶看到的html文件——》傳輸給用戶。
9、網頁製作時連接資料庫是怎麼寫的
曾經我跟你一樣 跟著視頻做的連接資料庫 後來問了客服才知道不能用 不支持 沒辦法 只能又學慣用代碼 呵呵 現在想想 其實也挺簡單的~~就這么幾句。。。 set conn=Server.CreateObject("ADODB.Connection") conn.Open "driver=Driver do Microsoft Access (*.mdb);uid=admin;DBQ="&Server.MapPath("db1.mdb") set rs=server.CreateObject("adodb.recordset") Sql="select * from [user] " rs.Open Sql,conn,1,3 ... rs.close set rs=nothing
滿意請採納
10、網頁設計的時候 資料庫的鏈接設置
配置好access的數據源
1)打開Dreamweaver 中站點面板並點擊編輯站點。
2)點擊「NEW」新建站點。
3)選擇「本地信息」選項,設置站點的名字以及文件存放路徑。
4)選擇「測試服務」選項設置解釋ASP的路徑(與IIS中設置的路徑一致)。
5)點擊確定完成創建工作。
2.ODBC與Dreamweaver的連接
1)在Dreamweaver中「application」面板里選擇「Database」選項,並單擊上面的「+」號,選擇下拉菜單中的第二項(DNS)。
2)設置資料庫在Dreamweaver中的名字,「connection name」是用於設置在Dreamweaver中用什麼名字代表這個連接,名字中只要不帶有數字就可以。「data source name」選擇在第二步中資料庫和ODBC建立連接時的名字,用戶名和密碼是在SQL Server中建立的用戶名和密碼,然後點擊「OK」就可以了。
到這里為止就已經把資料庫與Dreamweaver相連了。