Results 1 to 14 of 14

Thread: [RESOLVED] how to send over database info from sever to client?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    18

    Resolved [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

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: how to send over database info from sever to client?

    How are you calling it?

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    18

    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.

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    18

    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.

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    18

    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.

  8. #8
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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:
    1. private sub initForm
    2. Dim myAdapter As New OleDbDataAdapter()
    3. dim myDLL as ServerDLL.clsTest
    4.  
    5. Set myDll = New ServerDLL.clsTest
    6. myAdapter = myDLL.getWeekDayDA(...put parameters needed here...)
    7.  
    8. end sub


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    18

    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.

  10. #10
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    18

    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

  12. #12
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  13. #13
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    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...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  14. #14
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width