473,503 Members | 1,681 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

retrieving a single piece of data from a dataset

im trying (with great difficulty) to retrieve 1 item of data from a dataset

im trying to put the piece of data into a string from column 0 row 1

here is my code (i guess you will see what im trying to achieve)


Private Function checkduplicate(ByVal Surname As String, ByVal Firstname As
String, ByVal HouseNo As String, ByVal StreetName As String, ByVal Postcode
As String)
Dim conn As New System.Data.SqlClient.SqlConnection(SQLstrConn)
Dim sql As String = "CheckDuplicate '" & Surname & "','" & Firstname
& "','" & HouseNo & "','" & StreetName & "','" & Postcode & "'"
Dim da As New System.Data.SqlClient.SqlDataAdapter(sql, conn)
Dim ds As DataSet = New DataSet()
da.Fill(ds)
Dim RowCount As Integer = ds.Tables(0).Rows.Count
Dim ID As String
I need to set ID equal to column 0 row 1 here

If RowCount = 1 Then
Return ID
Else
Return "Record Does Not Exist"
End If
End Function
Thanks

Mike
Nov 20 '05 #1
1 1270
Sorry, I actually don't see what you are trying to do, other then to make
sure that at least one record came back.

But to get the first column of the first row, you would use
ds.Tables(0).Rows(0)(0). If there were no rows, this of course would throw
an exception.

Also, if all you need is one piece of information, consider using
ExecuteScalar of the SqlCommand object. If you really just need 1 piece of
information and that's it, filling a dataset is overkill.

"Mike Fellows" <mi***************@equityhouse.co.uk> wrote in message
news:hu*******************@newsfe5-gui.server.ntli.net...
im trying (with great difficulty) to retrieve 1 item of data from a dataset
im trying to put the piece of data into a string from column 0 row 1

here is my code (i guess you will see what im trying to achieve)


Private Function checkduplicate(ByVal Surname As String, ByVal Firstname As String, ByVal HouseNo As String, ByVal StreetName As String, ByVal Postcode As String)
Dim conn As New System.Data.SqlClient.SqlConnection(SQLstrConn)
Dim sql As String = "CheckDuplicate '" & Surname & "','" & Firstname & "','" & HouseNo & "','" & StreetName & "','" & Postcode & "'"
Dim da As New System.Data.SqlClient.SqlDataAdapter(sql, conn)
Dim ds As DataSet = New DataSet()
da.Fill(ds)
Dim RowCount As Integer = ds.Tables(0).Rows.Count
Dim ID As String
I need to set ID equal to column 0 row 1 here

If RowCount = 1 Then
Return ID
Else
Return "Record Does Not Exist"
End If
End Function
Thanks

Mike

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2224
by: Programatix | last post by:
Hi, I'm working on a project which includes WebServices and Windows Form application. The Windows Form application will call the WebServices to retrieve data from database. The data will be...
1
382
by: Terry | last post by:
My Question is this, I'm having trouble getting the OleDbDataAdapter to Point to another connection string and pull the data out of the DataSet I created from the Excel Spread Sheet and Place it up...
3
9736
by: Justin | last post by:
I have created a dataset with two tables and an insert command, I need to be able to retreive the Key Identity after inserting into table "A" for use in table "B". Should I use ExecuteScalar()...
6
16107
by: Dean Slindee | last post by:
Does anybody have an actual example of retrieving an Image data type column from a SQL Server table using a dataset (not a datareader)? I would like to see the statements that would move the...
0
2022
by: Andy | last post by:
Hi All. I'm working for a company that has set out a guideline for retrieving data from a database. Nobody can explain to me the reason for the following. When retrieving a set of records...
1
9433
by: jimmyfo | last post by:
Hi, I recently wrote an ASP.Net web application in VS2005 and published (using VS2005 Publish feature) it to a relatively clean machine with ASP.Net 2.0 and MDAC 2.8 installed on it. However, when...
5
2621
by: Randy Smith | last post by:
Hi ALL, I wonder if anyone has been using n-tier to bind to a GridView control by using the ObjectDataSource. This is our first OOP web application, and we have no tables. Right now we are...
7
15611
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
4
2115
by: indrajith_varma1 | last post by:
Hi I am working on an application to retrieve data from excel and insert into SQL Server database. Yesterday, I faced a strange problem. In a column in the excel, if 1st 8 rows are number, then...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7084
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7328
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7458
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5013
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.