Jump to content
  • Advertisement
Sign in to follow this  
sathenzar

Quick question ASP.NET 2.0 data query like PHP available?

This topic is 4789 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey everyone, I was just wondering if anyone could answer a quick question for me. In ASP.NET 2.0 I noticed there is a good amount of examples showing code to connect to a database and gain/display information like this:
SqlConnection myConnection = new SqlConnection(
    "server=(local)\\NetSDK;database=pubs;Integrated Security=SSPI");
SqlDataAdapter myCommand = new SqlDataAdapter("select * from Authors", myConnection);

DataSet ds = new DataSet();
myCommand.Fill(ds, "Authors");

MyDataGrid.DataSource=ds.Tables["Authors"].DefaultView;
MyDataGrid.DataBind();

... I'm used to PHP, is there a way to instead of applying to to a grid, just stick it in a string and gain information like PHP for ex. while($row mysql_Fetch_assoc($q)) { $img_path = $row[ 'image_path' ]; ... } Is there a way to do somthing like this simular in ASP.NET 2.0? Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
ETA: Sorry, suppose I could be more detailed if you're just starting out...


SqlConnection myConnection = new SqlConnection(
"server=(local)\\NetSDK;database=pubs;Integrated Security=SSPI");
SqlDataAdapter myCommand = new SqlDataAdapter("select * from Authors", myConnection);

SqlDataReader objRS = myCommand.ExecuteReader ();

try
{
while ( objRS.Read () )
{
string strImageFilename = (string)objRS [ "ImageFilename" ];
}
}
finally
{
objRS.Close ();
}


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!