How do i read data on the same row but on a different column from a mdb file using visual basic studio 2005.
so far i got : somethingDataSet.Tables(NameofTable).Rows.Find("StudnetID").Item("Name")
For example:
student ID Name
1 John
2 Matt
So if user put 1 it then the name should be John. And if 2 it should be Matt. However everytime i put 2, it gives me John. Could you guys help me with it
Hey Dave, Could you help me Thank you in advance

Help plz!
rashe
i serously dont need to add anything, i just need to read the data from that row that is it.
here are my codes. maybe it will be more helpful.
Private objConnection As OleDbConnection Private objCommand As OleDbCommand Private objDataAdapter As OleDbDataAdapter Private objDataSet As DataSet Private Sub Student()objDataAdapter =
New OleDbDataAdapterobjDataSet =
New DataSetobjDataAdapter.SelectCommand = objCommand
objDataAdapter.Fill(objDataSet,
"StudentTable")End Sub
Private
Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickobjConnection =
New OleDbConnection(strConnectionString)objCommand =
New OleDbCommandobjCommand.CommandText =
"StudentTable"objCommand.CommandType = CommandType.TableDirect
objCommand.Connection = objConnection
Call Student()
objDataSet.Tables("StudentTable").Rows.Find("StudentID").Item("StudentName") (studentid is already define and is an input from the user. so from this point I am just getting the student id to get the student name value.)
End Sub
Plz help me.hic hic
TaegerD
To answer your question:
To itterate(sp ) through your Rows you need to address which Row you want to read from i.e.:
somethingDataSet.Tables(NameofTable).Rows(INDEX).Item("Name")
Put the row number your looking for instead of the INDEX
Fdeveloper
Dim
ColumnValue As String = ds.Tables("TableName").Rows(RowNumber).Item("ColumnName").ToStringvaibhavsaxena17
Have you just tried adding the constraint to your DataTable object
somethingDataSet.Tables(NameofTable).Constraints.Add()
Juvenn
that is the same thing as saying:
somethingDataSet.Tables(NameofTable).Rows.Find("StudentID").Item("NameColumn")
but lol everytime i do that it will tell me that table doesnt have primary key even though my age column is a freaking primary key. i dont get it Samthing happened if i do it ur way.
Frank I. garcia
Ok here is another solution...use the select method of the table object to return the row(s) you need:
Dim drs as Datarow() = DataSet.Tables(NameOfTable).Select(StudentId = 2)
Dim dr as datarow = drs(0)
Dim ColumnValue as string = dr("Name").toString
Tryston02
rdrrichards
I dont think you can query a DataTable like a regular database.
What you could do though I think, is use the .Find function to retreive the DataRow your looking for and then you have all the columns to your disposal.
Dim myRow As DataRow = somethingDataSet.Tables(NameofTable).Rows.Find("StudnetID");
Dim myName As String = myRow("NameColumn");
Dim myAddress As String = myRow("AddressColumn");
Would that help
Glandorf
sparkymark75