Avatar billede bonden Nybegynder
21. april 2001 - 16:00 Der er 3 kommentarer og
1 løsning

Skal forbinde med databasen

<%
option explicit
Response.ExpiresAbsolute=now()-1

\'Initialize ado connection and open it
\'Response.Write \"Debug\"\'
\'Response.Flush

dim adoConn
set adoConn=Createobject(\"ADODB.Connection\")
\'adoConn.Open \"Driver={SQL Server};Server=;Uid=;Pwd=;Database=\"
adoConn.Open \"?\",\"Uid\",\"Pwd\"%>

Hvad skal der stå, der hvor jeg har skrevet et ?-tegn??
Der kommer en række \"include\" efter dette, hvoraf en af dem indeholder en del adoconn.......


Avatar billede perla Nybegynder
21. april 2001 - 16:35 #1
Taget fra ADO beskrivelsen

connectionobject.Open ConnectionString, UserID, Password, Options

The Open method is used to establish (open) a physical connection to a data source. Once the connection is live, you can execute commands against the data source.

There are four optional parameters.

The optional ConnectionString parameter is a string that contains the information needed to establish a connection to a data source. The string is composed of a series of parameter=value statements that are separated by semicolons. Note that the ConnectionString property inherits the values from the ConnectionString parameter of this method.

Please refer to the ConnectionString Property for examples.

ADO supports five arguments for this string. (This is the same format as the ConnectionString property.)

Provider= is the name of the provider. If you use this parameter, you cannot use the File Name= parameter.

File Name= is the name of a file that contains the connection information. If you use this parameter, you cannot use the Provider= parameter.

Remote Provider= is the name of the provider that you use when you open a client-side connection. (for Remote Data Service)

Remote Server= is the path name to the server that you use when you open a client-side connection. (for Remote Data Service)

URL= is the absolute URL address to use for the connection.

Note: Duplicate parameters are ignored and only the last occurrence of a repeated parameter is used.

The optional UserID parameter is a string containing the user name to use when making the connection.

The optional Password parameter is a string containing the password to use when making the connection.

The optional Options parameter is one of the ConnectOptionEnum constants which specify how the Connection object should return: synchronously (the default) or asynchronously.

ConnectOptionEnum Constants

Constant Value Description
adAsyncConnect 16 Open an asynchronous connection which returns before the connection is completed
adConnectUnspecified -1 Default, open a synchronous connection which returns after the connection is completed


Code (VBScript):
Dim objConnection
Set objConnection = Server.CreateObject(\"ADODB.Connection\")
objConnection.ConnectionString =
      \"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=GuruList\"
objConnection.ConnectionTimeout = 0
objConnection.Open

ADO beskrivelsen kan downloades her
http://www.activeserverpages.dk/download/default.asp?mode=download&id=137

-Per
Avatar billede bonden Nybegynder
21. april 2001 - 16:49 #2
Tak for svaret - det hjælper mig ikke umiddelbart, men kan da til nøds gå an.
Alt, hvad der står neden for ovennævnte kode skulle være ok, det er såmænd bare det lille spørgsmålstegn, jeg skal have en defenition for - om det er et navnet på en fil, en sti, eller hvad.....Men jeg vil kaste mig i studierne og se, hvad om jeg finder frem til noget...
Avatar billede perla Nybegynder
21. april 2001 - 16:55 #3
Fandt lige et eksempel.

<%  @LANGUAGE=\"VBSCRIPT\" %>
<%  Option Explicit %>
<!--#include File=\"adovbs.inc\"-->
<HTML>
    <BODY BGCOLOR=\"White\" topmargin=\"10\" leftmargin=\"10\">

    <!-- Your ASP Code goes here -->
<%
Dim Source
Dim Connect
Dim Rs1
   
Source = \"SELECT * FROM Authors\"
Connect = \"Provider=sqloledb;Data Source=srv;\" & _
    \"Initial Catalog=Pubs;User Id=sa;Password=;\"

Set Rs1 = Server.CreateObject( \"ADODB.Recordset\" )
Rs1.Open Source, Connect, adOpenForwardOnly
Response.Write(\"Success!\")
%>
    </BODY>
</HTML>

Og et link til lidt mere uddybende eksempel

http://msdn.microsoft.com/library/psdk/dasdk/mdae194k.htm

-Per
Avatar billede bonden Nybegynder
21. april 2001 - 17:02 #4
Det hjalp lidt mere - tak for det:-))
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester