Obviously your function will not work in that case. But you can make it generic(in the sense of the word) by passing the entire SQL string as a parameter and setting that parameter in the calling function.
Personally, I would recommend Stored Procedures. In addition to the security advantages, you would be able to deal with complicated SP's too. On Nov 19, 1:07 am, xshadow <[EMAIL PROTECTED]> wrote: > hello all, > > Well, I've successfully managed to access my data from MS > access 2007 DB through vb.net against a simple query with the > following code. > > Public Function DataSetFunc(ByVal TableName As String) As DataSet > Dim Connection As OleDbConnection = New OleDbConnection > (Constring) > Dim command As OleDbCommand = New OleDbCommand > Dim sql As String = "Select * from " & TableName > Connection.ConnectionString = Constring > Dim da As OleDbDataAdapter = New OleDbDataAdapter(sql, > Connection) > Dim ds As DataSet = New DataSet > da.Fill(ds, TableName) > Return ds > End Function > > I have following tables > costumer(cid, name, ........, address) > products(pid, name,........,price) > sale(sid,cid,pid,........,date) > > All goes well as far as the data is required from a single table i.e > "select * from costumer". > I want to know that what if need the data from multiple tables for > which I'll have to use joins in my query. I don't understand that what > table name would be specified in above function in order to use joins > in Select statement. Besides, I want to know that is there any > tutorial or stuff out there regarding this issue which demonstrates > that which things should be handled through application programing and > which ones should be handled through sql queries that we use fill > DataAdapter. Sorry if my question is not clear. > > bye :-)
