Jump to content
Xtreme .Net Talk

Recommended Posts

  • *Gurus*
Posted
Dim oConnection As New SqlConnection
Dim oCommand As New SqlCommand
Dim oDataReader As SqlDataReader

oConnection.ConnectionString = "user id=;password=;database=;server=;Connect Timeout=15"
oConnection.Open()

oCommand.Connection = oConnection
oCommand.CommandText = "SELECT * FROM myTable"

oDataReader = oCommand.ExecuteReader()

While oDataReader.Read()
   'Loop though data
End While

oDataReader.Close()
oConnection.Close()

  • 5 weeks later...
  • 3 weeks later...
Guest hesaigo999ca
Posted
Is ther any property that allows me to know if a connection object is closed (i.e. VB6 = if recordset.state = adstateopen then
  • 4 months later...
Posted

Can we open new reader while i doing loop of 1 reader?

example :

 

oDataReader = oCommand.ExecuteReader()

 

While oDataReader.Read()

'Loop though data

' At there contain read to other sql statement to retrieve info

End While

Posted

hi possiblydamp,

 

just a little bit confused as to checking the connection state using

the code

dim conn as System.Data.SqlClient.SQLConnection

 

if conn.State = ConnectionState.Closed 'Connection closed

 

end if

 

 

--------------------------------------------------------------------------------

as you stated above. i think this will check the connection state.

how exactly can i do it for a datset? like we do for recordset. is there any method.

 

also while searching in recordset using find command we can know the cursor position in the recordset.

 

in dataset.table.Select we can search the fields but can we get the location where the search stopped ?

 

help.

Posted

Hi Guys, I'm just doing a bit of research towards moving across to VB.Net and was wondering why you would use this method as opposed to using a SqlDataAdapter, which would utilize a disconnected SqlConnection. What are the advantages / disadvantages of each method.

 

Thanks

  • *Experts*
Posted

A datareader is a forward only read of data...very fast but only reads doesnt allow for dataset manipulation.

"Adapters are used to exchange data between a data source and a dataset.

In many applications, this means reading data from a database into a dataset,

and then writing changed data from the dataset back to the database. However,

a data adapter can move data between any source and a dataset. For example,

there could be an adapter that moves data between a Microsoft Exchange server and a dataset." (From the search of "Visual Basic and Visual C# Concepts")

Posted
Thanks for your help on tha above questions it was really informative. Just one more question. In n-tier applications that I previously developed, I often used recordsets to pass data back and forth across different tiers. How does this work in regards to DataAdapters and DataReaders.
  • *Experts*
Posted

Depends on how your going to implement the app. If you're serving up data across a large network,

the best way is asp.net. Uses the same disconnected dataset and all the work is done on the server.

No worries about cursors, the adapter takes care of that for you.

That what you're concerned about?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...