Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 3rd, 2005, 01:57 PM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to access sql server meta data using asp?

hi guyes i have a database in sql server 2000 and i want to write an asp script that using ado connection to that database and uses the metadata to display all the colums of a perticuler table.(no information about tables ,colums,datatypes, primary keys and foreign keys should be hardcoded). Could any one help me how i do this. Thanks

i want it to be quivelet to this one but instead of access sql server db:

<%@LANGUAGE="vbscript" CODEPAGE="1252"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<%

    sql="select * from players"

    set conn=Server.CreateObject("ADODB.Connection")
    conn.Provider="Microsoft.Jet.OLEDB.4.0"
    conn.Open(Server.Mappath("/db/TENNIS DATABASE.mdb"))
    set rs = Server.CreateObject("ADODB.recordset")
    rs.Open sql, conn



%>
</head>

<body>




<table width="200" border="1">
<tr>
    <td>Player ID</td>
    <td>Name</td>
    <td>Intials</td>
</tr>
<% while not rs.eof %>
<tr>
    <td><a href = "playerprofile.asp?person_id=<%=rs("playerno")%>"> <%=rs("playerno")%></a></td>
    <td><%=rs("name")%></td>
    <td><%=rs("initials")%></td>
</tr>
<% rs.movenext
wend
%>
</table>

</body>
<%
    rs.close
    set rs=nothing

%>
</html>
 
Old March 4th, 2005, 12:39 AM
Authorized User
 
Join Date: Feb 2005
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Please have the required ASP script below:

<%@LANGUAGE="vbscript" CODEPAGE="1252"%>
<%
    Dim sql,conn,rs,intNoOFields
    sql="select * from players"
    set conn=Server.CreateObject("ADODB.Connection")
    conn.Open("Provider=SQLOLEDB.1;User ID=sa;password=mypassword;Initial Catalog=MyDatabase;Data Source = MySQLServer;")
    set rs = Server.CreateObject("ADODB.recordset")
    rs.Open sql, conn
    intNoOFields = rs.Fields.Count
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<%If Not (rs.EOF And rs.BOF) Then%>
<table width="200" border="1">
  <tr>
  <% For i = 0 To intNoOFields - 1%>
        <th><%=rs(i).Name%></th>
  <% Next%>
  </tr>
  <% while not rs.eof %>
  <tr>
     <% For i = 0 To intNoOFields - 1%>
         <td><%=rs(i).Value%>&nbsp;</td>
     <% Next%>
  </tr>
  <% rs.movenext
  wend
  %>
</table>
<%end if%>
</body>
<%
    rs.close
    set rs=nothing
    conn.close
    set conn = nothing
%>
</html>



Cheers,
Pooja Falor
 
Old March 7th, 2005, 08:12 AM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for u reply. I want to run this code in xp pro sp2 computer but i get connection errors.

i do not know what should i put for its parameters based on my installation method!!
i tried all sort of paramaters and non worked .

conn.Open("Provider=SQLOLEDB.1;User ID=sa;password=mypassword;Initial Catalog=MyDatabase;Data Source = MySQLServer;")


the way i log to sql server :
using sql server service manager is by typing in LAPTOP in the server edit box and and pressing start!(no password)

The way i connect to query analyzer i type LAPTOP in sql server edit box and user windows authenticatin and login without any
password.

i be happy if some one help me run this on my system.thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
access data of excel sheet into sql server in asp KGANESH2006 SQL Server ASP 2 April 20th, 2006 02:33 AM
Access to Sql Server data export mateenmohd SQL Server 2000 4 February 14th, 2006 02:18 PM
Using Access with SQL Server Data npepin Access 4 July 21st, 2004 03:36 PM
SQL Access/ASP.NET data access issue saeta57 SQL Server ASP 1 July 4th, 2004 04:29 PM
SQL Access/ASP.NET data access issue saeta57 Classic ASP Databases 1 July 4th, 2004 03:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.