- 鐵幣
- 1107 元
- 文章
- 739 篇
- 聲望
- 65 枚
- 上次登入
- 08-11-9
- 精華
- 3
- 註冊時間
- 02-12-31
- UID
- 1261
|
這是我寫的..可不可以麻煩懂資料庫的大大看一下出了什麻問題
執行的時後出現找不到可安裝的 ISAM 找不到決解的方法 QQ
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<html>
<head>
</head>
<body>
<form runat="server">
</form>
<table>
<tr><td>性名:<asp:textBox id="user1" text="" runat="server" /><br></td></tr>
<tr><td>內容:<asp:textBox id="Message" textmode="Multiline" columns="30" rows="5" runat="server" /><br></td></tr>
<tr><td><asp:button id="bbb" text="送出" runat="server" /></tr></td>
<tr><td><asp:Label id="talkout" runat="server" /></tr></td>
</table>
</body>
</html>
<Script Language="VB" Runat="Server">
Dim objCon As OleDbConnection
Dim objCmd As OleDbCommand
Dim StrDbCon ="Provider=Microsoft.Jet.OLEDB.4.0;Data Cource=" & Server.Mappath("talk.mdb")
Sub Page_Load(sender As Object, e As EventArgs)
If isPostBack Then
addGuestBook()
End If
ViewGuestBook()
End Sub
Sub addGuestBook()
Dim strUser , strMessage , strSQL as string
strUser = user1.text
strMessage = Message.text
strSQL = "INSERT INTO Talk(Ttim,UserName,Message) "
strSQL &= "VALUES('" & DateTime.Now.Tostring() & "','"
strSQL &= strUser & "','"
strSQL &= Replace(strMessage,"'","''") & "')"
objCon = New OleDbConnection(strDbCon)
objCon.open()
objCmd = New OleDbCommand(strSQL , objCon)
objCmd.ExecuteNonQuery()
objCon.Close()
End Sub
Sub viewGuestBook()
Dim StrSQL , output As string
objCon = New OleDbConnection(strDbCon)
objCon.Open()
strSQL="SELECT * FROM 留言版 ORDER BY Ttime DESC"
objCmd = New OleDbCommand(strSQL, objCon)
Dim objDataReader As OleDbDataReader
objDataReader = objCmd.ExecuteReader()
While objDataReader.Read()
output &= "<b>日期</b><p>" & objDataReader.Item("Ttime") & "<br>"
output &= objDataReader.Item("UserName") & "說:" &"<br>"
output &= objDataReader.Item("Message") & "</p><hr>"
End While
objDataReader.Close()
objCon.Close()
talkout.text = output
End Sub
</Script> |
|