|
-
Feb 20th, 2006, 12:17 PM
#1
Thread Starter
Junior Member
[RESOLVED] how to send over database info from sever to client?
i have try to send over OleDbDataAdapter or dataset to client but i cant get it in clientside.
Public Function getWeekDayTBLDA() As OleDbDataAdapter
Dim sqlQ As String = "SELECT * FROM weekDayTBL"
Dim myAdapter As New OleDbDataAdapter(sqlQ, myConnection)
Return myAdapter
End Function
Or
Public Function getWeekDayTBLDS() As DataSet
Dim sqlQ As String = "SELECT * FROM weekDayTBL"
Dim myAdapter As New OleDbDataAdapter(sqlQ, myConnection)
Dim myDS = New DataSet("weekDayTBL")
myAdapter.Fill(myDS)
Return myDS
End Function
------------------------------------
In client side i cant use those fuction? why?
What i wanna do is connect a datagridview that show the databaseinfo
-
Feb 20th, 2006, 12:41 PM
#2
Re: how to send over database info from sever to client?
How are you calling it?
-tg
-
Feb 20th, 2006, 02:50 PM
#3
Thread Starter
Junior Member
Re: how to send over database info from sever to client?
imports Name
name.class.function but it is not working.
ex:
myDS = name.class.getWeekDayTBLDS()
i cant get the public function it just stop at name.class. 'cant get the function here'
the server is a DLL file
maybe i have to use a recordset instead but how?
Last edited by DreamB; Feb 20th, 2006 at 05:02 PM.
-
Feb 20th, 2006, 05:42 PM
#4
Re: how to send over database info from sever to client?
OK, so let me get this straight.
The DLL that has the class that this getWeekDayTBLDS function is located is on the server? Or does it exist on the client?
It has to be on the client PC, or you have to use remoting, or run it as a Web Service... Secondly, I don't see how you are creating the connection object either.
-tg
-
Feb 20th, 2006, 06:21 PM
#5
Thread Starter
Junior Member
Re: how to send over database info from sever to client?
the serverDLL is on the client PC.
i didnt write the connection on the sample code up there but the connections is fine 
the problem i have is not the connection..
it is about i cant get the public function from the server.. dont know why?
Last edited by DreamB; Feb 20th, 2006 at 08:14 PM.
-
Feb 20th, 2006, 10:27 PM
#6
Re: how to send over database info from sever to client?
Then you need to post more code... like where you are creating the instance to the DLL, setting the connection and calling the function. What you've posted isn't enough to figure out what is not working.
-tg
-
Feb 21st, 2006, 06:12 AM
#7
Thread Starter
Junior Member
Re: how to send over database info from sever to client?
hm.. ok. what i try to do is a n-tier applikation with a dll file as server that provide client with databaseinfo.
the dll will be in the sub folder then client but in same PC. just wanna seperat them logicaly, in dll i have:
module DBcon
Public defaultConStr As String = "Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=Northwind;Integrated Security=SSPI;"
Public myConnection As New OleDbConnection(defaultConStr)
Public Function getWeekDayTBLDA() As OleDbDataAdapter
Dim sqlQ As String = "SELECT * FROM weekDayTBL"
Dim myAdapter As New OleDbDataAdapter(sqlQ, myConnection)
myConnection.Open()
'shuold i close the connection b4 return?
'in Reader they have OleDbCommand.ExecuteReader() but how to execute oledbDataAdapeter?? maybe ExecuteNonQuery but how?
'or should i use Dataset as function return instead off dataadapter? witch is better?
Return myAdapter
End Function
' more func
' more func
' more func
End Module
Public Class clsTest
Public Function getWeekDayDA() As OleDbDataAdapter
Return DBcon.getWeekDayTBLDA
End Function
End Class
------------------------------
clent side:
i try to call the public funtion but cant reach it like:
class testFrm
private sub initForm
Dim myAdapter As New OleDbDataAdapter()
myAdapter = serverDLL.clsTest. 'here is the end cant call .getWeekDayDA'
'here i wanna shoow the databaseinfo in a datagridview... hm.. how to connect a datatgridview to a dataadapter or dataset??
It will help me alot if u guys can pose some sample code for datagridview... i am a newbie in VB so it will help me a lot.. tnx
end sub
hope this code is enought
Last edited by DreamB; Feb 21st, 2006 at 06:26 AM.
-
Feb 21st, 2006, 09:00 AM
#8
Re: how to send over database info from sever to client?
OK, that's what I thought.....
First, just so you know, what you are doing isn't necessarily n-tier architecture.... but that's beside the point.
In order to use a function or method in a DLL, you first have to create an instance to that class.
VB Code:
private sub initForm
Dim myAdapter As New OleDbDataAdapter()
dim myDLL as ServerDLL.clsTest
Set myDll = New ServerDLL.clsTest
myAdapter = myDLL.getWeekDayDA(...put parameters needed here...)
end sub
-tg
-
Feb 21st, 2006, 11:55 AM
#9
Thread Starter
Junior Member
Re: how to send over database info from sever to client?
TNX alot... helped me much
Last edited by DreamB; Feb 21st, 2006 at 12:31 PM.
-
Feb 21st, 2006, 12:34 PM
#10
Re: how to send over database info from sever to client?
Excellent! Could you mark the thread as resolved (found under the Tread Tools menu above).
-tg
-
Feb 21st, 2006, 07:33 PM
#11
Thread Starter
Junior Member
Re: [RESOLVED] how to send over database info from sever to client?
above i use: myConnection.Open()
when should i close the connection or dispose it?
Public Function getWeekDayTBLDA() As OleDbDataAdapter
Dim sqlQ As String = "SELECT * FROM weekDayTBL"
Dim myAdapter As New OleDbDataAdapter(sqlQ, myConnection)
myConnection.Open()
Return myAdapter
End Function
-
Feb 21st, 2006, 11:10 PM
#12
Re: [RESOLVED] how to send over database info from sever to client?
Actualy .... don't open it.... if you don't open it explicitly, then the connection will automatically open when you invoke the Fill method from the adapter, and close it automaticaly.
However, if you do open it explicitly like this, then yes, it's a good idea to close it.
-tg
-
Feb 21st, 2006, 11:35 PM
#13
Re: [RESOLVED] how to send over database info from sever to client?
It seems that the best practice in such is just let the DataAdapter handle the opening and closing the connection as needed, at least that's what I have heard...
-
Feb 22nd, 2006, 08:11 AM
#14
Re: [RESOLVED] how to send over database info from sever to client?
Strangely enough that is the new conventional wisdom...... goes against everything we knew about VB prior to .NET
-tg
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|