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

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

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")
...

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.