Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Visual Web Developer Do while not rs.eof

Status
Not open for further replies.

Esoteric

ISP
Feb 10, 2001
93
US
I am having some difficulties doing something very simple. Please help:

Here is what I have
Code:
Dim connstring As String = ConfigurationManager.ConnectionStrings("TIRESConnectionString").ConnectionString
        Dim conn As New SqlDataSource
        conn.ConnectionString = connstring
        conn.SelectCommand = "SELECT CID, CNAME, CSTATE FROM Customers"
What I want to do is something of this nature, but I can't get it to do it.
Code:
Dim connstring As String = ConfigurationManager.ConnectionStrings("TIRESConnectionString").ConnectionString
        Dim conn As New SqlDataSource
        conn.ConnectionString = connstring
        conn.SelectCommand = "SELECT CID, CNAME, CSTATE FROM Customers"
for each DataRow in _________

next

Most everything I find out there refers to commands that with Visual Web Developer i don't seem to have.... Any ideas?
 
I think you should use your specified Select Command on your connection to fill a DataTable. You will need to incorporate a DataAdapter as well I think. Then, for each DataRow in myDataTableName should do it for you?

Hope this helps,

Alex

Ignorance of certain subjects is a great part of wisdom
 
Something like this should work. It opens a connection the the sSQL server, creates a command object, executes and fills a data reader, and then walks through the data reader one line at a time.

Code:
Dim conSQLString As String = _
    & ConfigurationManager.ConnectionStrings("TIRESConnectionString").ConnectionString
Dim conSQL As New SqlConnection(conSQLString)
Dim strSQLString As String = "SELECT CID, CNAME, CSTATE FROM Customers;"
Dim commSQL = New SqlCommand(strSQLString, conSQL)
commSQL.CommandType = CommandType.Text

conSQL.Open()
Dim drSQL As SqlDataReader = commSQL.ExecuteReader
If drSQL.HasRows Then
    While drSQL.Read
        ' Do what you want for each row here
        ' Fields are references as drSQL("CID").ToString or drSQL("CNAME").ToString and so on
    End While
End If
conSQL.Close()

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB/Access Programmer
 
thanks guys got it all figured out.. Thanks a ton. lights finally came on in my head...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top