Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Database connection

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,51
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> Database connection
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Database connection - 5/24/2001 12:02:36 AM   
  eak_guy

 

Posts: 15
Score: 0
Joined: 5/23/2001
From: USA
Status: offline
How can i connect an access database in VBScript ? And how can i get those data in a grid control ? can you give some examples ?
 
 
Post #: 1
 
 Re: Database connection - 5/24/2001 12:05:50 AM   
  daydreamer

 

Posts: 19
Score: 0
Joined: 5/23/2001
From: USA
Status: offline
That's a very demanding task for VBScript.
Just what are you trying to achieve.
Might be easier to write the data access in a VB DLL and call it from VBScript.

Anyway, to access a MDB from a datagrid:

First, I would use either the reference or object tags so that VBScript would recognize the data grid and the ADO Recordset library.

Second, within the reference and object tags I would set the properties of the data grid including what database it is to be connected to.

Third, I'd write the SQL statements to access the database.

Good luck

(in reply to eak_guy)
 
 
Post #: 2
 
 Re: Database connection - 5/24/2001 12:08:15 AM   
  eak_guy

 

Posts: 15
Score: 0
Joined: 5/23/2001
From: USA
Status: offline
Thanks but can you be more broader with that ? Here a sample of my code as soon as i click the browse button an error occurs "Object Required : server"

<html>
<head>
<title>PC Inventory System</title>
<script language="VBScript" RUNAT="server">
<!--
sub cmdbrowse_onclick
msgbox "hello"
dim Conn, RS, strConn, sqlStatement
Set Conn = server.createobject("ADODB.Connection")

strConn = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="
strConn = strConn & server.mappath("..\ken\pcinvsys\sample.mdb") & ";"
Conn.Open
Set RS = createobject("ADODB.Recordset")
RS.activeconnection=Conn
rs.Cursortype=2 'adOpenDynamic
sqlStatement = "Select * from PCINV Where Users=""E. LOPEZ"""
RS.open sqlStatement
end sub
-->
</script>
</head>
<body>
<!--<OBJECT ID="DBGrid Control" WIDTH="100%" HEIGHT="100%" align="middle" NAME="grid" CLASSID="CLSID:00028C00-0000-0000-0000-000000000046">
</OBJECT> -->
<HR>
<!--<form method="POST" action="view.asp">
<p><input type="submit" value="View" name="View"></p>
</form> -->
<form>
<center>
<!--<input name="cmdbrowse" type="Image" title="View the contents" src="./img/icons/table.ico" width="40" height="40"> -->
<input name="cmdbrowse" type="Button" title="View the contents" Value="BROWSE" width="40" height="40">


<input name="cmdadd" type="Image" title="Add to the table " src="./img/icons/folder04.ico" width="40" height="40">

<input name="cmdedit" type="image" title="Edit the selected record" src="./img/icons/pencil01.ico" width="40" height="40">

<input name="cmddelete" type="Image" title="Delete the record(s)" src="./img/icons/delete.bmp" width="40" height="40">

<input name="cmdupdate" type="Image" title="Updates the table" src="./img/icons/save.bmp" width="40" height="40">
</center>
</form>
</body>
</html>


Thanks in advance... :)

(in reply to eak_guy)
 
 
Post #: 3
 
 Re: Database connection - 5/24/2001 12:09:51 AM   
  pedx

 

Posts: 16
Score: 0
Joined: 5/22/2001
From: USA
Status: offline
I use this code to test ODBC connections.

<html>
<head>
<title>
Connection Test
</title></head>

<body>
<%
dim myConn
set myConn = server.createobject("ADODB.Connection")

myConn.Open ODBCtest

If myConn.state = 1 then
response.write("Connection opened successfully<p>")
else
response.write("Error. Connection could not be opened.<P>")
end if

myconn.close
set myConn = Nothing

%>

</body>

</html>

(in reply to eak_guy)
 
 
Post #: 4
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> Database connection Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts