asp database
5 posts Page 1 of 1
asp database
hello,I want to connect database to my html website. I had follow asp tutorial of this site but its not working. pls help me . The code i tried is as follow
<html>
<head>
<title>Enter data into database</title>
</head>
<body>
<%
' Database connection - remember to specify path to your database
Set Conn = Server.CreateObject("ADODB.Connection")
DSN = "DRIVER = {Microsoft Access Driver (*. mdb)}; "
DSN = DSN & "DBQ=" & Server.MapPath("C:\Inetpub\wwwroot\DB1.mdb")
Conn.Open DSN
' The SQL statement is built
strSQL = "INSERT INTO Table1 ("
strSQL = strSQL & "Fname, "
strSQL = strSQL & "Lname) "
strSQL = strSQL & "VALUES("
strSQL = strSQL & "'Krishna', "
strSQL = strSQL & "'Raj')"
' The SQL statement is executed
Conn.Execute (strSQL)
' Close the database connection
Conn.Close
Set Conn = Nothing
%>
<h1>The database is updated!</h1>
</body>
</html>
Last edited by priyam on Mon Apr 22, 2013 6:50 pm, edited 1 time in total.
Re: asp database
What Error It Give it to you ?Re: asp database
XainPro wrote:What Error It Give it to you ?
m getting the following error: -
Error Type:
Server.MapPath(), ASP 0172 (0x80004005)
The Path parameter for the MapPath method must be a virtual path. A physical path was used.
/demo.asp, line 12
i have my site already hosted and want to provide database support to it. please help..
Re: asp database
this is complicated i would recommend you to hire a professional asp developer for this task !Re: asp database
<%response.write
(Server.MapPath("test.asp") &
"<br>")
response.write
(Server.MapPath("script/
test.asp") & "<br>")
response.write
(Server.MapPath("/script/
test.asp") & "<br>")
response.write
(Server.MapPath("\script") &
"<br>")
response.write
(Server.MapPath("/") &
"<br>")
response.write
(Server.MapPath("\") &
"<br>")
%>
Output:
c:\inetpub\wwwroot\script
\test.asp
c:\inetpub\wwwroot\script
\script\test.asp
c:\inetpub\wwwroot\script
\test.asp
c:\inetpub\wwwroot\script
c:\inetpub\wwwroot
c:\inetpub\wwwroot
yeh you now understand where you done a fatal mistake in your code.
I am too quite newbie in Asp.
--
My Passion Is Only Learning Nothing Else :)
My Passion Is Only Learning Nothing Else :)
Page 1 of 1