Visual Basic Sample Code on How to Establish via Internet Connection

0 comments

Posted on 3rd July 2011 by Admin in Visual Basic .Net

, , ,

‘Visual Basic can connect the database through the internet connection, this is very useful when you want to centralize the database or connect the different locations let say for example the company has three ‘branches in different cities or country so you must setup one for database server and the rest connect the server as client.

‘Visual Basic Sample Code

Dim RS As Recordset
Dim cnnGeneric As Connection
Set Conn = New Connection
Conn.Open

“Provider=MS Remote;” _
& “Remote Provider=MSDataShape;” _
& “Remote Server=http://www.mydomain.com;” _
& “Data Source=Employee;” _
& “User Id=myusername;Password=mypassword;”

Set RS = New Recordset

With RS
.CursorLocation = adUseClient
.Open strQuery, Conn, adOpenStatic, adLockReadOnly
.ActiveConnection = Nothing
End

With

Encapsulator of XML Features in SQL Server 2000

0 comments

Posted on 1st May 2010 by Admin in Database Programming |Visual Basic 6

,

This class acts as a re-useable object for calling Stored Procedures and SQL Queries that return XML from SQL Server 2000.
With a few lines of code, you can return XML from SQL Server to your application. You can pass multiple input parameters to the stored procedure as well as output parameters for returning singular data. It also lets you easily access @RETURN_VALUE parameters from your Stored Procedures so that business rules can be applied within the stored procedure. You can call multiple stored procedures and Queries with while sharing one connection. This class does all these things and hides the details from the programmer.
I have included a Visual Basic Project with this class, the project can be used to return straight XML to the client application. The project can retrieve XML from SQL Server via a Stored Procedure or an SQL statement with the ‘FOR XML [AUTO|RAW|EXPLICIT]‘ statement at the end.
I have also included an ASP page (CallSP.asp) and an XSL file (Products.xsl) to show an example of using the class from within ASP. The ASP page calls a stored procedure that has an input parameter and an output parameter. After the XML is returned to the page, we apply an XSL style sheet to transform it into straight HTML on the server using the MSXML2.DOMDocument object.
The examples use the Northwind Database that ships with SQL Server 2000. I also sent along a short sql script (SQL_Setup.sql) to create several stored procedure examples. The proper permissions must be set in SQL to view or execute the stored procedures from the Visual Basic Project as well as from an ASP Page.

Download Project