how i can convert this link from php to asp.net

Last post 09-26-2007 3:00 AM by er.tushar. 3 replies.

Sort Posts:

  • how i can convert this link from php to asp.net

    11-29-2004, 12:41 PM
    • Member
      25 point Member
    • nikolaoscy
    • Member since 11-15-2004, 9:09 AM
    • Posts 5
    1 <HTML>
    2 <?php
    3 $db = mysql_connect("localhost", "root", "");
    4 mysql_select_db("learndb",$db);
    5 $result = mysql_query("SELECT * FROM personnel",$db);
    6 echo "<TABLE BORDER=2>";
    7 echo"<TR><TD>Full Name<TD>Nick Name<TD>Options</TR>";
    9 while ($myrow = mysql_fetch_array($result))
    10 {
    11 echo "<TR><TD>".$myrow["firstname"]." ".$myrow["nick"];
    12 echo "<TD><a href=\"view.php?id=".$myrow[id]."\">View</a> ";
    13 echo "<a href=\"delete.php?id=".$myrow[id]."\">Delete</a>";
    14 }
    15 echo "</TABLE>";
    16 ?>
    17 </HTML>

    can i use statement like that on line 13 in order to pass the ID of the record i want to delete to mynext page using asp.net and specificaly C#?

    thank you
    Nicholas
  • Re: how i can convert this link from php to asp.net

    11-29-2004, 2:24 PM
    • Member
      25 point Member
    • nikolaoscy
    • Member since 11-15-2004, 9:09 AM
    • Posts 5
    i done this
    <td>Delete</td>

    but i get the following error: Compiler Error Message: CS1519: Invalid token '(' in class, struct, or interface member declaration

    how i can capture that datareader in my delete page?
  • Re: how i can convert this link from php to asp.net

    02-26-2007, 5:44 AM
    • Contributor
      3,084 point Contributor
    • Girijesh
    • Member since 10-27-2005, 12:04 PM
    • India
    • Posts 652

    nikolaoscy:
    1 2 "; 7 echo""; 9 while ($myrow = mysql_fetch_array($result)) 10 { 11 echo "
    Full NameNick NameOptions
    ".$myrow["firstname"]." ".$myrow["nick"]; 12 echo "View "; 13 echo "Delete"; 14 } 15 echo "
    "; 16 ?> 17 can i use statement like that on line 13 in order to pass the ID of the record i want to delete to mynext page using asp.net and specificaly C#? thank you Nicholas

    Is problem is still unsolved?

  • Re: how i can convert this link from php to asp.net

    09-26-2007, 3:00 AM
    • Member
      168 point Member
    • er.tushar
    • Member since 01-21-2006, 11:46 AM
    • India
    • Posts 40

     Hi,

    That can be done easily. Moreover you can use the code on line no 13. But in that case, when u use Delete.aspx, you can access the query parameters like this:
             Request.QueryString["ProductID"]
    Remember that you will always get string in return. In case you want to use it as integer, you'll have to parse it.

     There are many ways of converting this code. I am jotting down the simplest way of doing it, as it is written in PHP (just changing the syntax) (Assuming that you'll be using SQL Server).

    On Page_Load function :

     

    StringBuilder content = new StringBuilder();

    content.Append("<TABLE BORDER=2> <TR><TD>Full Name<TD>Nick Name<TD>Options</TR>");
    SqlConnection con = new SqlConnection("server=localhost;user=tushar;password=pwd;database=asp");
    SqlCommand cmd  = con.CreateCommand();
    cmd.CommandText = " Select * from personnel";
    SqlDataReader reader = cmd.ExecuteReader();
    while(reader.Read())
    {

           content.Append("<TR><TD>" + reader["FirstName"].ToString() + reader["LastName"].ToString() );
           ........
           ........

    }
    content.Append("</table>");
    reader.Close();
    con.Close();
    Response.Write(content.ToString());

     

    I hope this helps.

     

    Regards,

    Tushar 

     

    Regards,
    Tushar
Page 1 of 1 (4 items)