Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connect to DB on Web Server from VB

Status
Not open for further replies.

dpdoug

Programmer
Nov 27, 2002
455
US
Is there any way to connect to a remote database on a web server like you can with ASP/VBScript?

The reason is that there are several drawbacks for using a web-based interface -- basically when you want to pull data into HTML controls to edit then save back to the database. Data gets chopped off at the first blank space in the data -- this is inacceptable. Also some of the undesireable limitations of ASP.

The app will be a desktop admin program anyway and not public access.

VB doesn't have these drawbacks. I know this is possible since StoreFront 5.0 has a Web Admin program that connects to a Web server DB and it doesn't have a web-based inteface.

I know it will still be a stateless app, but I can live with that.

David

 
There may be a better way but what I did was set up an ODBC connection and used the following code:

Dim Cn As New Connection, Rs As New Recordset

' Sets all connections and recordset to nothing on execution
Set Cn = Nothing
Set Rs = Nothing

' Connects to remote database and pulls current orders (orders w/o extract date).
Cn.ConnectionString = "DSN=XXXXX;UID=XXXXX;PWD=XXXXX"
Cn.Open

Rs.Source = "SELECT * FROM [XXXXX].orders WHERE " _
& "(order_extract_date IS NULL);"
Set Rs.ActiveConnection = Cn

' Fills Recordset with orderdata
Rs.Open Swi
 
Great Swi. This would work fine on a network.
But how does the connection object know how to locate the web server over the internet? This is my primary question.

dpdoug
 
Try this:

Scroll down to:
To connect to SQL Server running on a remote computer (via an IP address)
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
try using connection strings like the following:

Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DbName;Data Source=ServerName;User ID Uid;pwd=Pwd;

note:
for the connection to work ur system must be connected to the net.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top