Results 1 to 8 of 8

Thread: old fashion!

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2001
    Location
    Lebanon,Beirut
    Posts
    48

    old fashion!

    hi there,
    well my problem might sound silly to many of you. When i write in vb 6 i used to write my own connection strings, define my own recordsets,etc... now in vb.net im completly unaware of it. what i need is an exple where u manually connect to a db, select some records to show in a datagrid ,update statement, and delete records from it. is that still possible?

    thank you guys in advance, hope didnt sound like a really old grandpa
    There is,we are,abou il zoulouf,mijana w mal3ona

  2. #2
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    here's a basic example of opening an access database in .net and adding the contents of a table to a DataGrid :
    VB Code:
    1. Imports System.Data.OleDb
    2. '///^^^ top of your form's code window.
    3. '////////
    4.  
    5.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    6.         Dim Connection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "C:/bin.mdb"
    7.         Dim Command As String = "SELECT * FROM binFrm"
    8.         OpenAccessFile(Connection, Command)
    9.     End Sub
    10.  
    11.     Private Sub OpenAccessFile(ByVal strConnection As String, ByVal strCommand As String)
    12.         Dim objDbConnection As New OleDbConnection(strConnection)
    13.         objDbConnection.Open() '///open a new connection.
    14.  
    15.         Dim objCommand As New OleDbCommand(strCommand, objDbConnection)
    16.         Dim objAdaptor As OleDbDataAdapter
    17.         objAdaptor = New OleDbDataAdapter(objCommand)
    18.         Dim objDataSet As New DataSet()
    19.         objAdaptor.Fill(objDataSet, "binFrm")
    20.         DataGrid1.DataSource = objDataSet.Tables("binFrm") '///fill a datagrid with the recordset
    21.  
    22.         objDbConnection.Close()
    23.         objCommand.Dispose()
    24.         objAdaptor.Dispose()
    25.         objDataSet.Dispose()
    26.     End Sub
    hope that helps to get you started
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2001
    Location
    Lebanon,Beirut
    Posts
    48
    thank you for yr reply! it was really helpfull, but may i ask for one more thing.

    str_sql="update tablename set fieldname=1"

    how can i write a query like the above to update a certain record in VB .net.

    thank you
    There is,we are,abou il zoulouf,mijana w mal3ona

  4. #4
    Addicted Member
    Join Date
    Aug 1999
    Posts
    164
    Originally posted by leghalbon
    thank you for yr reply! it was really helpfull, but may i ask for one more thing.

    str_sql="update tablename set fieldname=1"

    how can i write a query like the above to update a certain record in VB .net.

    thank you
    str_sql="update tablename set fieldname=1, fieldname2='aa' where id=25"
    -Shurijo

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2001
    Location
    Lebanon,Beirut
    Posts
    48
    hehehe, oups i did it again, my question turned out wrong.
    what i meant was whats the code, i mean how do i define the recorset, how do i excute the update in VB .NET , it's not about the query it self, its about executing an uodate or delete query

    sorry for my honest mistake...

    thank you
    There is,we are,abou il zoulouf,mijana w mal3ona

  6. #6
    Lively Member
    Join Date
    Oct 2002
    Posts
    67
    May I recommend ado.net core reference by MS Press ado.net has changed from ado enough, that you basically need to entirely re-educate yourself on the manner.

  7. #7
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Originally posted by Iamthewalrus15
    May I recommend ado.net core reference by MS Press ado.net has changed from ado enough, that you basically need to entirely re-educate yourself on the manner.
    I second that advice. This is a great book, if you want to know the ins and outs of ADO.NET. Another great book is Pragmatic ADO.NET.

  8. #8
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Here is how to execute OleDbCommands .
    http://www.vbforums.com/showthread.p...ghlight=update

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