Zaloguj | Zarejestruj | FAQ
Anonymous

asp database

+ Odpowiedz

Posty: 5 Strona 1 z 1


asp database

przez priyam » So kwi 13, 2013 12:50 pm

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>

Ostatnio edytowano Pn kwi 22, 2013 6:50 pm przez priyam, łącznie edytowano 1 raz

Avatar użytkownika

priyam

  • Posty: 3
  • Dołączył(a): Wt kwi 09, 2013 12:46 pm

Re: asp database

przez XainPro » Pn kwi 15, 2013 9:46 pm

What Error It Give it to you ?
Avatar użytkownika

XainPro

  • Posty: 3933
  • Dołączył(a): Pt lut 17, 2012 8:10 pm

Re: asp database

przez priyam » Pn kwi 22, 2013 7:01 pm

XainPro napisał(a):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..
Avatar użytkownika

priyam

  • Posty: 3
  • Dołączył(a): Wt kwi 09, 2013 12:46 pm

Re: asp database

przez XainPro » Wt kwi 23, 2013 9:38 pm

this is complicated i would recommend you to hire a professional asp developer for this task !
Avatar użytkownika

XainPro

  • Posty: 3933
  • Dołączył(a): Pt lut 17, 2012 8:10 pm

Re: asp database

przez phpsingh » Pn kwi 29, 2013 2:35 am

<%
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.
Avatar użytkownika

phpsingh

  • Posty: 29
  • Dołączył(a): Pt lis 09, 2012 6:08 am
--
My Passion Is Only Learning Nothing Else :)


+ Odpowiedz

Strona 1 z 1