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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SqlDataSource connectionstring and OleDbConnection?

Status
Not open for further replies.

FancyPrairie

Programmer
Oct 16, 2001
2,917
US
Using Visual Studio, I've dragged a SQLDataSource onto my page and configured and tested it. I need to execute the Select statement defined in the SqlDataSource via code. So I assumed I would use the OleDbConnection. But, I'm unable to assign the ConnectionString of the SqlDataSource as the ConnectionSting for the OleDbConnection. Code looks like this:
Code:
using cnn as New OleDbConnection(SqlDataSource.ConnectionString)
strSQL = "Select..."
Dim oCommand as New OleDbCommand(strSQL, cnn)
cnn.Open()
...
My question is, how can I use the ConnectionString of the SqlDataSource as the ConnectionSting in OleDbConnecton?
 
1st problem... you are using a DataSource control don't. you cannot debug them.
2nd problem... sqldatasource controls only work with MSSql.

the solution. use OldDbConnection objects in code behind (or better yet in a unit of work implementation) and wire the events and data in codebehind, not markup.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top