Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To 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 May 2nd, 2007, 09:11 AM
Registered User
 
Join Date: May 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Read SQL Server DB using .ASP-VB

I am trying to connect an .ASP Page to a MS SQL Server Database to read data, code below, its not working any ideas with Code below

<%
Dim oConn, oRs
Dim qry, connectstr, fieldname, tablename
Dim db_name, db_username, db_userpassword
Dim db_server
db_server = "end-novsql1"
db_name = "StoreRepairs"
db_username = "StoreRepairUser"
db_userpassword = "5t0re5"
fieldname = "callid"
tablename = "dbo_Call"
connectstr = "Driver={SQL Server};SERVER=" & db_server & ";DATABASE=" & db_name & ";UID=" & db_username & ";PWD=" & db_userpassword
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open connectstr
qry = "SELECT * FROM " & tablename
Set oRS = oConn.Execute(qry)
%>
<table width = 600 border="1">
    <tr>
           <td width="300"><strong>CallID</strong></td>
    </tr>
    <% Set oRS = oConn.Execute(qry)
    if not oRS.EOF then
    while not oRS.EOF
    %>
    <tr>
        <td width="200">
<%= oRs.Fields("CallID") %></td>
    </tr>
    <% oRS.close
    end if

    Set oRs = nothing
    Set oConn = nothing
    %>
 
Old May 11th, 2007, 12:08 AM
Authorized User
 
Join Date: Sep 2003
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to prabodh_mishra
Default

you are missing
    oRS.MoveNext
    WEND
just before oRS.Close

Cheers,
Prabodh





Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a SQL Server DB through VB code tknnguyen VB Databases Basics 2 July 2nd, 2008 11:28 AM
Accessing a SQL Server Express DB thru VB Express djelavic SQL Server 2005 2 February 21st, 2006 07:53 PM
access db to sql server db mikersantiago Classic ASP Basics 4 November 16th, 2004 03:33 AM
read-only probs in msaccess db using asp form anupamda Classic ASP Databases 1 February 10th, 2004 12:03 PM





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