|
-
Aug 7th, 2007, 06:43 PM
#1
Thread Starter
Fanatic Member
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
-
Aug 7th, 2007, 07:17 PM
#2
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Aug 7th, 2007, 07:17 PM
#3
Re: How to get VB6 Recordset functionality from within .Net
You may want to read tutorials in DB FAQ - it's under VB.Net subtitle.
-
Aug 8th, 2007, 05:33 AM
#4
Thread Starter
Fanatic Member
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
-
Aug 8th, 2007, 07:41 AM
#5
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.
-
Aug 8th, 2007, 10:42 AM
#6
Thread Starter
Fanatic Member
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
-
Aug 8th, 2007, 10:51 AM
#7
Re: How to get VB6 Recordset functionality from within .Net
What is the current code that you are running?
-
Aug 8th, 2007, 12:59 PM
#8
Thread Starter
Fanatic Member
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
-
Aug 8th, 2007, 01:00 PM
#9
Re: How to get VB6 Recordset functionality from within .Net
 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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Aug 8th, 2007, 02:47 PM
#10
Thread Starter
Fanatic Member
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()
-
Aug 8th, 2007, 06:25 PM
#11
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
-
Aug 9th, 2007, 03:55 AM
#12
Thread Starter
Fanatic Member
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.
-
Aug 9th, 2007, 05:07 PM
#13
Thread Starter
Fanatic Member
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
-
Aug 9th, 2007, 05:25 PM
#14
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
-
Aug 10th, 2007, 09:48 AM
#15
Thread Starter
Fanatic Member
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
|