Results 1 to 15 of 15

Thread: How to get VB6 Recordset functionality from within .Net

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2006
    Posts
    612

    How to get VB6 Recordset functionality from within .Net

    This is how I did it in VB6 with Access how do I do these things in VB 2005 with CE Compact?

    ‘OPEN CONNECTION, CREATE RECORDSET and GET VALUES FROM DATABASE
    Code:
    Set Connect = New ADODB.Connection
    Connect.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\maxi.mdb;Jet OLEDB:Database Password=IO34peration;"
    Connect.Open
    Set RS = New ADODB.Recordset
    RS.Open "PetT1", Connect, adOpenKeyset, adLockPessimistic, adCmdTable
    RS.MoveFirst
    NF = CDbl(Encrypt(RS.Fields("8").Value, KeyJs))
    RS.Close
    Set RS = Nothing
    SAVE DATA
    Code:
    Set RS = New ADODB.Recordset RS.Open "PurejetT1", Connect, adOpenKeyset, adLockPessimistic, adCmdTable
            RS.MoveFirst
            RS.Fields("6").Value = Encrypt((CStr(JF)), KeyJs)
    RS.Update
    RS.Close
    Set RS = Nothing

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to get VB6 Recordset functionality from within .Net

    You shouldnt use ADO in .NET as its depreciated. You should use ADO.NET. See mendhaks intro to ADO.NET tutorial for a good walk through.

    http://vbforums.com/showthread.php?t=466658
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    May 2006
    Posts
    612

    Re: How to get VB6 Recordset functionality from within .Net

    Many thanks for that but

    Using this tutorial http://vbforums.com/showthread.php?t=466658

    I have downloaded and reviewed this example, can I use this same code systax for a MS SQL Compact database ? as this example uses an access database

  5. #5
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: How to get VB6 Recordset functionality from within .Net

    The beauty of using ADO is its flexibility - most often all you'll have to do is to change connection sting, provider.
    For proper connection string check "connection strings" link in my signature.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    May 2006
    Posts
    612

    Re: How to get VB6 Recordset functionality from within .Net

    Thanks for that but now I have an error message MicroSoft.SQLSERVER.MOBILE.OLEDB.3.0 provider is not registered on the local machine

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How to get VB6 Recordset functionality from within .Net

    What is the current code that you are running?

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    May 2006
    Posts
    612

    Re: How to get VB6 Recordset functionality from within .Net

    http://vbforums.com/showthread.php?t=466658

    But I have changed the connection string for a connection to a SQL CE Compact Database

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to get VB6 Recordset functionality from within .Net

    Quote Originally Posted by JohnSavage
    Edit:
    If you changed your connectionstring for sql ce you shouldnt get errors. Can you post what code you are using?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    May 2006
    Posts
    612

    Re: How to get VB6 Recordset functionality from within .Net

    This is the connection string

    Code:
    conn.ConnectionString = "Provider=Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source=C:\Users\John Savage\Database\MyDatabase#1.sdf;User Id=admin;Password=;SSCE:Encrypt Database=True;"
    and if it helps this is the error detail

    System.InvalidOperationException was unhandled
    Message="The 'Microsoft.SQLSERVER.MOBILE.OLEDB.3.0' provider is not registered on the local machine."
    Source="System.Data"
    StackTrace:
    at System.Data.OleDb.OleDbServicesWrapper.GetDataSource(OleDbConnectionString constr, DataSourceWrapper& datasrcWrapper)
    at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
    at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
    at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
    at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
    at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
    at System.Data.OleDb.OleDbConnection.Open()
    at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
    at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
    at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
    at ADONetTutorial1.Form2.Form2_Load(Object sender, EventArgs e)
    at System.EventHandler.Invoke(Object sender, EventArgs e)
    at System.Windows.Forms.Form.OnLoad(EventArgs e)
    at System.Windows.Forms.Form.OnCreateControl()
    at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
    at System.Windows.Forms.Control.CreateControl()
    at System.Windows.Forms.Control.WmShowWindow(Message& m)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
    at System.Windows.Forms.ContainerControl.WndProc(Message& m)
    at System.Windows.Forms.Form.WmShowWindow(Message& m)
    at System.Windows.Forms.Form.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
    at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
    at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
    at System.Windows.Forms.Control.set_Visible(Boolean value)
    at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
    at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
    at System.Windows.Forms.Application.Run(ApplicationContext context)
    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
    at ADONetTutorial1.My.MyApplication.Main(String[] Args)
    at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
    at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Threading.ThreadHelper.ThreadStart()


  11. #11
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: How to get VB6 Recordset functionality from within .Net

    btw - it seems a DATASET is close to the old VB6 read-write recordset. You can read and write to it.

    The DATAREADER appears to be a forward-only type of structure.

    See this discussion...

    http://www.vbforums.com/showthread.php?t=482228

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    May 2006
    Posts
    612

    Re: How to get VB6 Recordset functionality from within .Net

    I am making progress but it's slow, these are the changes I have made to the tutorial

    Imports System.Data.SqlServerCe
    Imports System.Data.SqlClient

    Dim da As New SqlCeDataAdapter()
    Dim conn As New SqlCeConnection()

    SqlCeCommand used to replace OLBCommand in the code systax

    Now I get this error

    An error occurred creating the form. See Exception.InnerException for details. The error is: Unable to load DLL 'sqlceme30.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

    Any takers
    Last edited by JohnSavage; Aug 9th, 2007 at 04:00 AM.

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    May 2006
    Posts
    612

    Re: How to get VB6 Recordset functionality from within .Net

    I also just changed the connection string to

    Code:
    conn.ConnectionString ="Data Source=C:\Users\John Savage\Database\MyDatabase#1.sdf;Persist Security Info=False;"
    As per connectionstrings.com

    But I still get the error message

  14. #14
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: How to get VB6 Recordset functionality from within .Net

    Google found that error message - check out the links...

    http://www.google.com/search?hl=en&q...=Google+Search

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  15. #15

    Thread Starter
    Fanatic Member
    Join Date
    May 2006
    Posts
    612

    Re: How to get VB6 Recordset functionality from within .Net

    Hi

    Thanks I have followed that link and found the solution was to add sqlceme30.dll and all the other dll's that begin with sqlce to the project files.

    However having done this I still get the error message above that 'sqlceme30.dll' cannot be found

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