Re: Brand Spankin' Newbie ADO.NET Question



You said the magic words.
I would approach your problem by trapping the OnChange event of a TextBox
and passing the Value (filtered) to a Parameter used in a DataAdapter Fill
method SelectCommand query. The query itself would use a TOP clause to
return only enough rows to fill the visible rows of the grid and no more.
The Fill returns a DataSet populated with a DataTable that can be bound to
the DataGridView via the DefaultDataView. Make sure to clear the DataTable
each time or you'll get appended results.

hth
Incidentally, I don't mind if my readers contact me directly. The $1 or so I
get in royalties for the book is your ticket ;)

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"Eric Robinson" <eric @ pmcipa..{com}> wrote in message
news:cqaxe.1821$Si3.1187@xxxxxxxxxxx
> 1. Before posting to the group, I had already successfully negotiated a
> couple of the walkthroughs, but was unable to achive the kind of
> functionality that I wanted. For example, I want a real-time search field
> that causes the resultset displayed in the DataGrid to become
> progressively narrower with each keystroke. This is a very typical
> approach, but it seems that I would have to roll my own ADO.NET code to
> accomplish it, no?
>
> 2. I am already pretty familiar with OOP. I once wrote an ActiveX control
> that has now been downloaded thousands of times by developers in more than
> 50 countries around the world. I'm not a full-time professional
> programmer, but I keep my hand in, so to speak. I'm a newbie to ADO.NET,
> but not to OOP in general.
>
> 3. I don't understand why the code works OK in your VS 2003 but not in
> mine. Do I have a reference missing or something? This is very perturbing.
>
> 4. Sorry for the direct e-mail. I've been posting to forums since FIDONET
> was king and nobody had heard of USENET, so I've read the rules of
> netiquette more than once. I've seen people get in flame wars about
> top-posting and spamming (a term that originally referred to cross-posting
> to multiple newsgroups) and all kinds of things, so I know the difference
> between bad form and good form. Nevertheless, sometimes I get desperate
> and take chances. ;-)
>
> 4. We have several SQL servers of various flavors. The current project is
> built on SQL 2000.
>
> 5. I ordered your book. :-)
>
> --Eric
>
> "William (Bill) Vaughn" <billvaRemoveThis@xxxxxxxxxx> wrote in message
> news:eArWUSdfFHA.2484@xxxxxxxxxxxxxxxxxxxxxxx
>>I pasted your code into my VS.NET 2003 and it works fine... However, when
>>I first pasted it in, it did not see the Dim dtMyTable line. I had to
>>reenter it and it compiled fine. I think you're on the right track here,
>>but just taking the rocky road instead of the freeway... ;)
>> (It's also bad form to email people directly from the list...)
>> 'create the data set
>>
>>>> Dim DS As New DataSet
>>
>>>>
>>
>>>> 'create a datatable
>>
>>>> Dim dtMyTable As New DataTable("tblMyTable")
>>
>>>>
>>
>>>> 'create a column in the table
>>
>>>> Dim dcLastName As New DataColumn("LastName", GetType(String))
>>
>>>> dtMyTable.columns.add(dcLastName) <-Problem is with this line.
>>
>>>>
>>
>>
>> --
>> ____________________________________
>> William (Bill) Vaughn
>> Author, Mentor, Consultant
>> Microsoft MVP
>> www.betav.com/blog/billva
>> www.betav.com
>> Please reply only to the newsgroup so that others can benefit.
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>> __________________________________
>>
>> "William (Bill) Vaughn" <billvaRemoveThis@xxxxxxxxxx> wrote in message
>> news:OPAq7NdfFHA.3940@xxxxxxxxxxxxxxxxxxxxxxx
>>> Okay... I would probably get started with a database of some kind. MSDE
>>> comes to mind or SQL Express. But that's not absolutely necessary. If
>>> you have a database, creating the objects can be done with drag-and-drop
>>> in Visual Studio. However, building the objects by hand is one of the
>>> harder things to accomplish if you're not familiar with OO programming.
>>> Fortunately, there are several good walkthroughs that should help. Have
>>> you tried the "Walkthrough: Creating a DataSet with Tables, Keys and
>>> ...."?
>>> There are several others that can help get you started. I have a bunch
>>> of examples in my Apress book "ADO.NET and ADO Examples and Best
>>> Practices" that are designed for developers moving from ADO classic.
>>> ____________________________________
>>> William (Bill) Vaughn
>>> Author, Mentor, Consultant
>>> Microsoft MVP
>>> www.betav.com/blog/billva
>>> www.betav.com
>>> Please reply only to the newsgroup so that others can benefit.
>>> This posting is provided "AS IS" with no warranties, and confers no
>>> rights.
>>> __________________________________
>>>
>>> "Eric Robinson" <eric @ pmcipa..{com}> wrote in message
>>> news:mo%we.3360$iv3.642@xxxxxxxxxxx
>>>>I am writing an application to maintain a directory of doctors and
>>>>healthcare providers. I could do it easily with ADO in VB6, but I want
>>>>to take advantage of this opportunity to learn VB.NET and ADO.NET.
>>>>
>>>> Toward that end, I am takinbg my first baby steps into ADO.NET. I
>>>> believe I understand the architechure well enough to get started, but
>>>> my initial efforts have been thwarted by the fact that VB.NET does not
>>>> seem to recognize the ADO.NET objects even though I seem to have the
>>>> right references and imports.
>>>>
>>>> --Eric
>>>>
>>>>
>>>> "William (Bill) Vaughn" <billvaRemoveThis@xxxxxxxxxx> wrote in message
>>>> news:eJ76zmbfFHA.2512@xxxxxxxxxxxxxxxxxxxxxxx
>>>>> What are you trying to do? What problem are you trying to solve?
>>>>>
>>>>> --
>>>>> ____________________________________
>>>>> William (Bill) Vaughn
>>>>> Author, Mentor, Consultant
>>>>> Microsoft MVP
>>>>> www.betav.com/blog/billva
>>>>> www.betav.com
>>>>> Please reply only to the newsgroup so that others can benefit.
>>>>> This posting is provided "AS IS" with no warranties, and confers no
>>>>> rights.
>>>>> __________________________________
>>>>>
>>>>> "Eric Robinson" <eric @ pmcipa..{com}> wrote in message
>>>>> news:ypSwe.13395$2S.2391@xxxxxxxxxxx
>>>>>> I'm trying to write my first ADO.NET application. In my form, I
>>>>>> have:
>>>>>>
>>>>>> <snip>
>>>>>>
>>>>>> Imports System.Reflection
>>>>>> Imports System.Data
>>>>>> Imports System.Data.OleDb
>>>>>> Imports System.Data.SqlClient
>>>>>> Imports System.Data.Odbc
>>>>>> Imports System.Data.Common
>>>>>> Imports System.IO
>>>>>> Imports System.Text.RegularExpressions
>>>>>>
>>>>>> Public Class Form1
>>>>>> Inherits System.Windows.Forms.Form
>>>>>>
>>>>>> <Windows Generated Code Not Shown>
>>>>>>
>>>>>> 'create the data set
>>>>>> Dim DS As New DataSet
>>>>>>
>>>>>> 'create a datatable
>>>>>> Dim dtMyTable As New DataTable("tblMyTable")
>>>>>>
>>>>>> 'create a column in the table
>>>>>> Dim dcLastName As New DataColumn("LastName", GetType(String))
>>>>>> dtMyTable.columns.add(dcLastName) <-Problem is with this line.
>>>>>>
>>>>>> End Class
>>>>>>
>>>>>> </snip>
>>>>>>
>>>>>> The problem is with the second to last line. VB underlines
>>>>>> "dtMyTable" with a squiggly line, with the error message "Expected
>>>>>> declaration." Note that "columns" and "add" are not capitalized
>>>>>> because VB does not recognize the object.
>>>>>>
>>>>>> What am I missing?
>>>>>>
>>>>>> --Eric
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>


.



Relevant Pages

  • Re: sql command problem
    ... This posting is provided "AS IS" with no warranties, and confers no rights. ... >> Microsoft MVP ... >> Please reply only to the newsgroup so that others can benefit. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: adding a group to local computer
    ... Please no e-mails, any questions should be posted in the NewsGroup This posting is provided "AS IS" with no warranties, and confers no rights. ... why must all your domain users be local admin? ...
    (microsoft.public.windows.server.active_directory)
  • Re: DC question
    ... any questions should be posted in the NewsGroup This ... posting is provided "AS IS" with no warranties, and confers no rights. ... Global catalog server and DNS server. ...
    (microsoft.public.windows.server.active_directory)
  • Re: Windows 2008: Cant create new GPOs
    ... This posting is provided "AS IS" with no warranties, and confers no rights. ... any questions should be posted in the NewsGroup ...
    (microsoft.public.windows.server.active_directory)
  • RE: Migrate SQL 2000 system
    ... That newsgroup is primarily for issues involving SQL. ... We recommend posting ... Now we bought one new server to replace the old ...
    (microsoft.public.windows.server.migration)