CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Database Connection

Print topic Send  topic

Author Message
advcomputer

Posts: 68
Posted: 02/21/2007, 3:04 PM

How can I open a database and recordset connections on a page that does not have a database control such as a grid?

-Jeff
View profile  Send private message
Tuong Do
Posted: 02/21/2007, 6:36 PM

Assume you define a Codecharge connection called Connection1

<code>
Dim Conn
Set Conn = new clsDBConnection1
conn.open
</code>


"advcomputer" <advcomputer@forum.codecharge> wrote in message
news:645dcd00ad9131@news.codecharge.com...
> How can I open a database and recordset connections on a page that does
> not have
> a database control such as a grid?
>
> -Jeff
> _________________
> Jeff Goldstein
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

advcomputer

Posts: 68
Posted: 02/22/2007, 1:37 PM

OK, that looks pretty simple.. Now..

How would I execute a sql command and save it to a recordset. Everytime I try I get ADO errors regarding the recordset?

Any help would be appreciated,

Thx in advance,

jeff
View profile  Send private message
Tuong Do
Posted: 02/22/2007, 3:12 PM

The folowing example taken from Code charge helpNOTE : Replace
DBConnection1 with Conn (Your openned connection)Function
UserInfo_BeforeShow(Sender)
Dim SQL
Dim RecordSet
Dim UserId
Dim UserName
Dim WorkPhone

' Read user_id from URL
UserId = CCGetFromGet("user_id", 0)

If UserID > 0 then
SQL = "SELECT emp_name, phone_work FROM employees WHERE emp_id="&UserId
' Open the recordset
Set RecordSet = DBConnection1.Execute(SQL)
If DBConnection1.Errors.Count = 0 Then
If NOT RecordSet.EOF then
UserName = CCGetValue(RecordSet, "emp_name")
WorkPhone = CCGetValue(RecordSet, "phone_work")
End if
' Close the recordset
RecordSet.Close
Set RecordSet = Nothing
Else
Print "SQL Execution Failed."
DBConnection1.Errors.Clear
End If

' Show a label value
UserInfo.Value = UserName & ", phone: "&WorkPhone
Else
UserInfo.Visible = False
End if
End Function

"advcomputer" <advcomputer@forum.codecharge> wrote in message
news:645dcd00ad9131@news.codecharge.com...
> How can I open a database and recordset connections on a page that does
> not have
> a database control such as a grid?
>
> -Jeff
> _________________
> Jeff Goldstein
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

advcomputer

Posts: 68
Posted: 02/23/2007, 7:51 AM

Tuong Do,

Thank you for all of your help. I modified the code for my usgae and it works perfect. I do have one or two quick questions.

At the end of this function show we not also put;

conn.close to close the db connection?

Also, not that I know how to loop through the recordset, how can tell how many rows were fetched from the query and put into the recordset. I tried using the floowing;

Recordset.RecourdCount and it keeps displaying -1

Again and help would be appreciated and thank you for the time and patience.

-Jeff
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.