Jump to content
  • Advertisement
Sign in to follow this  

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

This topic is 4607 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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!