What does this fill function do

H

hon123456

Dear all,

I am new to .net environment. I have a code example as
follows:

<WebMethod()> Public Function GetCities(ByVal State As String) As
DataSet
Dim dsn As String =
"server=<servername>;database=<databasename>;uid=sa;pwd="
Dim myconnection As SqlConnection = New SqlConnection(dsn)
Dim mycommand As SqlDataAdapter = New SqlDataAdapter("select
city from citystate where state='" & State & "' order by city",
myconnection)

Dim ds As New DataSet()
mycommand.Fill(ds, "city")
Return ds
End Function


Could someone elaborate what is the use and meaning of "city"
in mycommand.Fill (ds."city")
 
C

C-Services Holland b.v.

hon123456 schreef:
Dear all,

I am new to .net environment. I have a code example as
follows:

<WebMethod()> Public Function GetCities(ByVal State As String) As
DataSet
Dim dsn As String =
"server=<servername>;database=<databasename>;uid=sa;pwd="
Dim myconnection As SqlConnection = New SqlConnection(dsn)
Dim mycommand As SqlDataAdapter = New SqlDataAdapter("select
city from citystate where state='" & State & "' order by city",
myconnection)

Dim ds As New DataSet()
mycommand.Fill(ds, "city")
Return ds
End Function


Could someone elaborate what is the use and meaning of "city"
in mycommand.Fill (ds."city")
The returned dataset will have a datatable named "city". Datasets can
have multiple datatables with different names.
You can access that datatable like this: ds.tables("city").rows.count
for instance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top