basic advice please re ado.net
basic advice please re ado.net
basic advice please re ado.net
basic advice please re ado.net
basic advice please re ado.net
basic advice please re ado.net basic advice please re ado.net basic advice please re ado.net basic advice please re ado.net basic advice please re ado.net basic advice please re ado.net basic advice please re ado.net basic advice please re ado.net
basic advice please re ado.net basic advice please re ado.net
basic advice please re ado.net
Go Back  Xtreme Visual Basic Talk > > > basic advice please re ado.net


Reply
 
Thread Tools Display Modes
  #1  
Old 12-13-2017, 10:06 AM
starmanMike starmanMike is offline
Junior Contributor
 
Join Date: Oct 2005
Location: near Norwich, UK
Posts: 310
Default 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.
Reply With Quote
Reply

Tags
dim, text, data, box, dataset, boxes, string, module, sql, foundrow, thestar, con, typo, message, vb.net, purposes, testing, binding, user, enters, enter, details, display, term, valid


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
basic advice please re ado.net
basic advice please re ado.net
basic advice please re ado.net basic advice please re ado.net
basic advice please re ado.net
basic advice please re ado.net
basic advice please re ado.net basic advice please re ado.net basic advice please re ado.net basic advice please re ado.net basic advice please re ado.net basic advice please re ado.net basic advice please re ado.net
basic advice please re ado.net
basic advice please re ado.net
 
basic advice please re ado.net
basic advice please re ado.net
 
-->