Click here to Skip to main content
16,008,183 members
Home / Discussions / Database
   

Database

 
GeneralRe: Complex SQL View Pin
Dayekh27-Sep-06 3:48
Dayekh27-Sep-06 3:48 
GeneralRe: Complex SQL View Pin
albCode27-Sep-06 3:58
albCode27-Sep-06 3:58 
QuestionInsert Record in Tables Pin
shapper27-Sep-06 1:18
shapper27-Sep-06 1:18 
AnswerRe: Insert Record in Tables Pin
Mike Dimmick27-Sep-06 2:13
Mike Dimmick27-Sep-06 2:13 
QuestionHow to search a dataset Pin
Rip Kirby27-Sep-06 0:11
Rip Kirby27-Sep-06 0:11 
AnswerRe: How to search a dataset Pin
Kschuler27-Sep-06 8:41
Kschuler27-Sep-06 8:41 
GeneralRe: How to search a dataset Pin
Rip Kirby27-Sep-06 23:48
Rip Kirby27-Sep-06 23:48 
GeneralRe: How to search a dataset Pin
Kschuler28-Sep-06 3:05
Kschuler28-Sep-06 3:05 
I think you've probably had trouble finding information on this because you don't really search a DataSet...You would do the search on a DataTable. There are a number of ways to perform a search on a DataTable object, I'll tell you about one. First of all, since a DataSet is a collection of DataTable objects, you can reference a table IN a DataSet like this:
dsMyDataSet.Tables("myTableName")
or, if for example you knew the table you wanted was the first table inserted into the DataSet:
dsMyDataSet.Tables(0)

So one way to search the DataTable requires that you first have a primary key constraint on the table. If you got the data for this DataSet from a data base by using a DataAdapter and doing a .Fill the constraints are not necessarily carried over into the DataSet. You may have to do something like this:
With dsMyDataSet.Tables("dtMyTable")<br />
    .Constraints.Add("pk", .Columns("PrimaryKeyColumnName"), True)<br />
End With

The "pk" parm gives a name to the new contraint for referencing it later, the .Columns("PrimaryKeyColumnName") parm specifies which column in the DataTable is the primary or unique key, and the True parm specifies that this is a primary key. This works when just one column makes up your primary key, if you have more than one column as a primary key the .Columns("PrimaryKeyColumnName") parm should be replaced by an array of DataColumns from the DataTable that compose the Primary Key.

Once you are sure that your DataTable has a primary key constraint you can search for a row like this:
Dim rowFound As DataRow<br />
rowFound = dt.Rows.Find("myKeyValue")

or if your primary key is a number:
Dim rowFound As DataRow<br />
rowFound = dt.Rows.Find(1003)


I hope this helps.
GeneralRe: How to search a dataset Pin
Rip Kirby28-Sep-06 9:25
Rip Kirby28-Sep-06 9:25 
QuestionGetting Maximum number: Pin
Shahzad.Aslam26-Sep-06 23:55
Shahzad.Aslam26-Sep-06 23:55 
AnswerRe: Getting Maximum number: Pin
albCode27-Sep-06 1:02
albCode27-Sep-06 1:02 
AnswerRe: Getting Maximum number: Pin
Rob Graham27-Sep-06 2:27
Rob Graham27-Sep-06 2:27 
AnswerRe: Getting Maximum number: Pin
Eric Dahlvang27-Sep-06 3:40
Eric Dahlvang27-Sep-06 3:40 
QuestionEncrypt in Dotnet and Decrypt in SQL 2000 Pin
Prash.26-Sep-06 21:54
Prash.26-Sep-06 21:54 
QuestionHow to write if i have 3 condition for WHERE? Pin
cheeken2u26-Sep-06 20:21
cheeken2u26-Sep-06 20:21 
AnswerRe: How to write if i have 3 condition for WHERE? Pin
albCode27-Sep-06 4:05
albCode27-Sep-06 4:05 
QuestionIDENT_CURRENT Pin
Polymorpher26-Sep-06 19:15
Polymorpher26-Sep-06 19:15 
QuestionHow to excute parameterized storeprocedure in LinkedServer Pin
Rickey_Me26-Sep-06 18:55
Rickey_Me26-Sep-06 18:55 
QuestionProblem with SELECT query using ADO.NET and C# Pin
Baz26-Sep-06 10:06
Baz26-Sep-06 10:06 
AnswerRe: Problem with SELECT query using ADO.NET and C# Pin
indianet26-Sep-06 10:40
indianet26-Sep-06 10:40 
AnswerRe: Problem with SELECT query using ADO.NET and C# Pin
Rob Graham26-Sep-06 16:27
Rob Graham26-Sep-06 16:27 
GeneralRe: Problem with SELECT query using ADO.NET and C# Pin
Baz26-Sep-06 21:54
Baz26-Sep-06 21:54 
AnswerRe: Problem with SELECT query using ADO.NET and C# Pin
Edbert P26-Sep-06 18:10
Edbert P26-Sep-06 18:10 
GeneralRe: Problem with SELECT query using ADO.NET and C# Pin
Baz26-Sep-06 21:46
Baz26-Sep-06 21:46 
AnswerRe: Problem with SELECT query using ADO.NET and C# Pin
albCode27-Sep-06 1:05
albCode27-Sep-06 1:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.