•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 397,650 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,389 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser:
Views: 3957 | Replies: 2
![]() |
•
•
Join Date: Nov 2004
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
Hi Peeps,
I am new to this forum, I am trying to create a weblog to allow users who are registered in a database I create in Access to create a blog entry which will be displayed on the screen to every one. I have created the database i Access and can manage some how using Dreamweaver to display contents of the database BUT THE QUESTION NOW IS, HOW DO I USE A FORM TO ENTER INFORMATION INTO THE DATABASE PLEASE! HELP ME AM DESPRATE.THANKS A MILLION... :-| :-|
I am new to this forum, I am trying to create a weblog to allow users who are registered in a database I create in Access to create a blog entry which will be displayed on the screen to every one. I have created the database i Access and can manage some how using Dreamweaver to display contents of the database BUT THE QUESTION NOW IS, HOW DO I USE A FORM TO ENTER INFORMATION INTO THE DATABASE PLEASE! HELP ME AM DESPRATE.THANKS A MILLION... :-| :-|
•
•
Join Date: Feb 2003
Location: London, England
Posts: 281
Reputation:
Rep Power: 7
Solved Threads: 6
THere is a bult-in form creation wizard in Access. This will obviously limit data entry and retreival to one computer or possibly multiple clients on a LAN.
If you need remote Web Access as you imply, then you'll need something more complicated. Generally, Access is not good online as it's slow and cannot handle more than one request simultaneously. If you really want it, you can use it, but you should be aware that there are a raft of free database servers that are significantly faster online.
If you need remote Web Access as you imply, then you'll need something more complicated. Generally, Access is not good online as it's slow and cannot handle more than one request simultaneously. If you really want it, you can use it, but you should be aware that there are a raft of free database servers that are significantly faster online.
•
•
Join Date: Jan 2005
Location: Sheffield, UK
Posts: 294
Reputation:
Rep Power: 4
Solved Threads: 6
I have been using asp and Access to create a forum (see www.basket2go.net/forum.asp). Scripts to add data to DB is listed below. Hope it may help:
' Get user name
ForumUser = Request.Form("user")
' re-structure the message in useable form
mssg = Trim(Request.Form("mssg"))
mssg = Server.HTMLEncode(mssg)
mssg = Server.URLEncode(mssg)
mssg = Replace(mssg, Chr(13), "<br>")
mssg = Replace(mssg, "'", "´")
PostMssg = "<p class=bbody><b>" & ForumUser & "</b> <span class=stext>Posted on " & Now() & " GMT</span></p>"
PostMssg = PostMssg & "<p class=body>" & mssg & "</p><hr color=#EFEFEF>"
' check action
Select Case Request.Form("action")
Case "newpost"
' get the next PostID
Dim nDB, nRS, nSTR, nSQL
Set nDB = Server.CreateObject("ADODB.Connection")
set nRS = Server.CreateObject("ADODB.Recordset")
nSTR = "Driver={Microsoft Access Driver (*.mdb)};" & "dbq="&server.MapPath("db/dbForum.mdb") & ";"
nDB.Open nSTR
nSQL = "SELECT * FROM tblPost Order By PostID ASC"
SET nRS = nDB.Execute(nSQL)
While Not nRS.EOF
PostID = nRS("PostID")
nRS.MoveNext
WEND
PostID = CInt(PostID) + 1
PostTitle = Trim(Request.Form("title"))
' open database and add new record
nSQL = "Insert Into tblPost (PostID, PostDate, PostTitle, PostMssg)" &_
" Values ('"&PostID&"', '"&Now()&"', '"&PostTitle&"', '"&PostMssg&"')"
nDB.Execute nSQL
' Close and destroy all objects
nRS.Close
nDB.Close
Set nRS = Nothing
Set nDB = Nothing
' send user back to the forum he/she come from
Response.redirect "forum.asp"
Case "response"
' add response to existing forum
' open database to retrive existing message and number of replies
Dim rDB, rRS, rSTR, rSQL
' Open database for shopping cart
Set rDB = Server.CreateObject("ADODB.Connection")
set rRS = Server.CreateObject("ADODB.Recordset")
rSTR = "Driver={Microsoft Access Driver (*.mdb)};" & "dbq="&server.MapPath("db/dbForum.mdb") & ";"
rDB.Open rSTR
rSQL = "SELECT * FROM tblPost WHERE PostID = '"&Request.Form("id")&"'"
SET rRS = rDB.Execute(rSQL)
While Not rRS.EOF
PostReply = CInt(rRS("PostReply")) + 1
PostMssg = rRS("PostMssg") & PostMssg
rRS.MoveNext
WEND
' Close and destroy all objects
rRS.Close
Set rRS = Nothing
' update database with new data
rSQL = "Update tblPost SET PostDate = '"&Now()&"', PostMssg = '"&PostMssg&"', " &_
" PostReply = '"&PostReply&"' WHERE PostID = '"&Request.Form("id")&"'"
rDB.Execute rSQL
' Clean up
rDB.Close
Set rDB = Nothing
' send user back to the forum he/she come from
Response.redirect "forum_display.asp?id=" & Request.Form("id")
Case Else
' if not both cases, i.e. an error
Response.redirect "forum.asp"
End Select
Good luck.
' Get user name
ForumUser = Request.Form("user")
' re-structure the message in useable form
mssg = Trim(Request.Form("mssg"))
mssg = Server.HTMLEncode(mssg)
mssg = Server.URLEncode(mssg)
mssg = Replace(mssg, Chr(13), "<br>")
mssg = Replace(mssg, "'", "´")
PostMssg = "<p class=bbody><b>" & ForumUser & "</b> <span class=stext>Posted on " & Now() & " GMT</span></p>"
PostMssg = PostMssg & "<p class=body>" & mssg & "</p><hr color=#EFEFEF>"
' check action
Select Case Request.Form("action")
Case "newpost"
' get the next PostID
Dim nDB, nRS, nSTR, nSQL
Set nDB = Server.CreateObject("ADODB.Connection")
set nRS = Server.CreateObject("ADODB.Recordset")
nSTR = "Driver={Microsoft Access Driver (*.mdb)};" & "dbq="&server.MapPath("db/dbForum.mdb") & ";"
nDB.Open nSTR
nSQL = "SELECT * FROM tblPost Order By PostID ASC"
SET nRS = nDB.Execute(nSQL)
While Not nRS.EOF
PostID = nRS("PostID")
nRS.MoveNext
WEND
PostID = CInt(PostID) + 1
PostTitle = Trim(Request.Form("title"))
' open database and add new record
nSQL = "Insert Into tblPost (PostID, PostDate, PostTitle, PostMssg)" &_
" Values ('"&PostID&"', '"&Now()&"', '"&PostTitle&"', '"&PostMssg&"')"
nDB.Execute nSQL
' Close and destroy all objects
nRS.Close
nDB.Close
Set nRS = Nothing
Set nDB = Nothing
' send user back to the forum he/she come from
Response.redirect "forum.asp"
Case "response"
' add response to existing forum
' open database to retrive existing message and number of replies
Dim rDB, rRS, rSTR, rSQL
' Open database for shopping cart
Set rDB = Server.CreateObject("ADODB.Connection")
set rRS = Server.CreateObject("ADODB.Recordset")
rSTR = "Driver={Microsoft Access Driver (*.mdb)};" & "dbq="&server.MapPath("db/dbForum.mdb") & ";"
rDB.Open rSTR
rSQL = "SELECT * FROM tblPost WHERE PostID = '"&Request.Form("id")&"'"
SET rRS = rDB.Execute(rSQL)
While Not rRS.EOF
PostReply = CInt(rRS("PostReply")) + 1
PostMssg = rRS("PostMssg") & PostMssg
rRS.MoveNext
WEND
' Close and destroy all objects
rRS.Close
Set rRS = Nothing
' update database with new data
rSQL = "Update tblPost SET PostDate = '"&Now()&"', PostMssg = '"&PostMssg&"', " &_
" PostReply = '"&PostReply&"' WHERE PostID = '"&Request.Form("id")&"'"
rDB.Execute rSQL
' Clean up
rDB.Close
Set rDB = Nothing
' send user back to the forum he/she come from
Response.redirect "forum_display.asp?id=" & Request.Form("id")
Case Else
' if not both cases, i.e. an error
Response.redirect "forum.asp"
End Select
Good luck.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb MySQL Marketplace
Similar Threads
- Writing to an Access Database (Visual Basic 4 / 5 / 6)
- VB: Connect to Access database via ODBC datasource name (Visual Basic 4 / 5 / 6)
- Disable access to .htaccess (Linux Servers and Apache)
- Writing to an Access Database using Java... (Java)
Other Threads in the MySQL Forum
- Previous Thread: Connecting to MySQL
- Next Thread: Saving Code in PHP


Linear Mode