GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Simple ASP.NET C# Question (https://gfy.com/showthread.php?t=567468)

Validus 01-24-2006 04:49 AM

Simple ASP.NET C# Question
 
Greetings guys, maybe somebody can help. I am working with C#.

This is what I got:

<%
string MyVar; // define a variable
MyVar = Request.QueryString["MyVar_url"]; // add value
%>

I am trying to grab the MyVar_url value from the URL and asign it to the MyVar varaible. I want to add it to a to this later one...


SelectCommand="SELECT * FROM users WHERE user_id = @ MyVar "


But that is the second step.

Any help would be appreciated.

Validus 01-24-2006 07:11 AM

I think I am mixing run time code with compiled stuff. Umpf!

woj 01-24-2006 08:31 AM

Is this for a school project or something?

Validus 01-24-2006 08:34 AM

It is for me to learn a little ASP.NET C# :)

pstation 02-16-2006 12:12 PM

old post, but if you're using sql server it would look something like this....

Code:

<%
string MyVar = Request.QueryString["MyVar_url"];

...

SqlConnection sqlConn = new SqlConnection(connectionString);
sqlConn.Open();

SqlCommand cmd = new SqlCommand("SELECT * FROM users WHERE user_id = @MyVar", sqlConn);
cmd.Parameters.Add("@MyVar", SqlDbType.Int).Value = int.Parse(MyVar);
SqlDataReader result =        cmd.ExecuteReader();

sqlConn.Close();
%>

of course, much needed exception handling is missing, but it should give you a general idea of how it could be done :)


All times are GMT -7. The time now is 06:55 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123