0

Hi! everyone can some one share a piece of light with me is it possible to manipulate database access inside a class constructor.Cause i can create a connection but don't know how i'm going to things like data adapter an data set since.Any link Any Help Is appreciated.thanks

3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by Jostra
0

It would probably be possible, but I would probably rethink why there are database calls inside of the constructor. I would rather split it out into a separate call.

Here's a link to a Microsoft Patterns and Practices article. If it can't answer questions about how to handle database connectivity then I don't know what will:

http://msdn.microsoft.com/en-us/library/ms978510.aspx

0
public class DBClass
     ... 
     public Function GetTable(Sql as String) as DataTable
         Dim Adp as new SqlDataAdapter(sql,CnStr)
         Dim  Dt as New DataTable
         Adp.Fill(Dt)
         Return Dt
     End Function

End Class
.....
....
Dim cs as new DBClass
Dim Ds as new DataSet("TestDS")
Ds.Tables.Add(cs.getTable("Select * from Table1"),"Table1")
...
0

Thanks adapost i truly didnt know this like i said on my thread, can you please explain to me how do i define an adapter in a class. i appreciate thank

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.