ObjectSharp Blogs

You are currently viewing

Dave Lloyd's 2 Cents

A .NET Developer's Perspective


Connecting a .NET Datawindow to SQLServer

You may have noticed during the install of .NET DataWindow that there are no native drivers for SQL server. Sybase expects you to use OleDB to make the connection.

In case anyone is having trouble here is how to do it.

First you create the OleDBConnection object and pass that to an AdoTransaction Object. The AdoTransaction Object wraps up an ADO.Net users connection and Transaction objects so they can be used by the Datawindow.

Your code would look like this:

'Create a new OleDB Connection Object, Populate the ConnectionString Property and open the connection
Dim theConnection As New System.Data.OleDb.OleDbConnection
theConnection.ConnectionString = "Server=localhost;Provider=SQLOLEDB;Initial Catalog=Northwind;User ID=sa;Password=sa;"
theConnection.Open()

'Create a new AdoTransaction Object the constructor takes the connection object you created
Dim ADOTrans = New Sybase.DataWindow.AdoTransaction(theConnection)
'Binds the ADO.NET connection to the database interaction layer so that the AdoTransaction object can be used by a DataWindow
ADOTrans.BindConnection()

'Tell the DataWindow what Transaction Object to use
Me.DataWindowControl.SetTransaction(ADOTrans)

 

Comments

  • dave July 27, 2006 1:58 AM

    Thanks. I coded the above. but when I retrieve I faced problem in line 37 below

    Error:
    "Invalid operation: Retrieve because the DataStore has no transaction."

    "Source Error:
    Line 35:
    Line 36: Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    Line 37: WDW_1.Retrieve()
    Line 38: End Sub
    Line 39: End Class

    Please reply what I have to do???
    please copy mail to eswarmoorthi.subbiah@arabbanking.com if you have reply

Leave a Comment

(required) 
(optional)
(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS