Xtreme Visual Basic Talk

Xtreme Visual Basic Talk (http://www.xtremevbtalk.com/)
-   .NET Database and Reporting (http://www.xtremevbtalk.com/-net-database-and-reporting/)
-   -   basic advice please re ado.net (http://www.xtremevbtalk.com/-net-database-and-reporting/328885-basic-advice-please-re-ado-net.html)

starmanMike 12-13-2017 09:06 AM

basic advice please re ado.net
 
Hi, having very recently started with vb.net I am having a couple of problems with databases, not least the terminology! But am I right in thinking that a vb.net data adapter sort of equals a vb6 data control and a dataset = recordset? Also, not sure how to access the fields in the dataset. So far I have this:
Code:

Module modDB
    Dim con As New OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =" & frmDatabase.thedb)
    Dim sql As String

    Public Sub Searchforstar(db As String, thestar As String)
        sql = "SELECT * FROM starcharts where starname = ' " & thestar & "'"
        Dim dataadapter As New OleDb.OleDbDataAdapter(sql, con)
        Dim ds As New DataSet()
        con.Open()
        dataadapter.Fill(ds)
        con.Close()
        Dim foundrow() As Data.DataRow
        foundrow = ds.Tables("charts").Rows(0).Item("starname")
        If foundrow.Length = 0 Then
            MsgBox("Star is not in the database")
        Else

            'display the details in the text boxes. One example below for testing purposes...
            frmDatabase.txtVariable.Text = ds.Tables("charts").Rows(0).Item("starname")
'even though there will only ever be one row returned.

        End If
    End Sub
End Module

So if the user (say) enters a typo that's not in the data set they get the message box, otherwise the text boxes get filled with the results from the appropriate field. I don't want design-time data binding because I need the text boxes empty to start with.
I have experimented putting a typo in the text box and hitting a button (which calls the above sub) and I do indeed get the message box. However if I do enter a valid search term nothing happens.


All times are GMT -6. The time now is 12:11 AM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Search Engine Optimisation provided by DragonByte SEO v2.0.15 (Lite) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
All site content is protected by the Digital Millenium Act of 1998. Copyright©2001-2011 MAS Media Inc. and Extreme Visual Basic Forum. All rights reserved.
You may not copy or reproduce any portion of this site without written consent.