Results 1 to 2 of 2

Thread: release recordset to database

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2015
    Posts
    1

    release recordset to database

    i'm using VB6
    i want programming in VB.NET
    i made an example but i am not able to release a recordset modified into database.
    can someone help me, please?
    here is the code of the example i made

    '-------------------
    Imports System.Data.OleDb
    Public Class Form3
    Public Cn As New ADODB.Connection
    Public Rs As New ADODB.Recordset
    .
    .
    .
    .
    Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Cn.ConnectionString = "Provider = Microsoft.Jet.OleDB.4.0;Data source= C:\Prod.Mdb"
    Cn.Open()
    Rs.ActiveConnection = Cn
    Rs.CursorLocation = ADODB.CursorLocationEnum.adUseClient 'adUseClient
    Rs.CursorType = ADODB.CursorTypeEnum.adOpenStatic 'adOpenStatic
    Rs.LockType = ADODB.LockTypeEnum.adLockBatchOptimistic 'adLockBatchOptimistic
    Rs.Open("MMat
    End Sub

    Private Sub TextBox1_DoubleClick(sender As Object, e As EventArgs) Handles TextBox1.DoubleClick

    ListBox1.Visible = Not ListBox1.Visible
    If ListBox1.Visible Then
    VediList1()
    ListBox1.Items.Clear()
    Rs.Sort = Rs.Fields(1).Name
    Rs.MoveFirst()
    Do
    ListBox1.Items.Add(Rs.Fields(0).Value + " " + Rs.Fields(1).Value)
    Rs.MoveNext()
    If Rs.EOF Then Exit Do
    Loop
    End If
    End Sub
    .
    .
    .
    .
    .
    Private Sub FineToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles FineToolStripMenuItem.Click
    Rs.Close()
    Rs.ActiveConnection = Nothing
    Cn.CommitTrans()
    Cn.Close()
    Cn.ConnectionString = Nothing
    Me.Close()
    End Sub
    .
    .
    .
    .
    .
    .
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Rs.AddNew()
    Rs.Fields(0).Value = "GIGI1"
    Rs.Fields(1).Value = "tetrametilparadiamminodifenilmetano"
    Rs.Update()

    End Sub
    '---------
    thank you
    italico

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,461

    Re: release recordset to database

    If you're using VB.NET then why are you using a Recordset at all? You should be using ADO.NET rather than ADO, i.e. populating a DataTable using a data adapter for data you want to retain or a data reader for data you want to read and discard. I suggest that you follow the Database FAQ link in my signature below and check out the .NET links there, including some of my own code examples.

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