c# help for my asp.net page

  • Thread starter Thread starter g_sharad
  • Start date Start date
G

g_sharad

Hi

I am freelancer and designing a .net page.

I require the syntax in C# for capturing the variable from carryover
line in url eg: www.xyz.com/ccc.aspx?mid=12

how to capture this mid in c# and I have to use in my sql string along
with Select * from Tbname where mid = 12.

can yu pls help me with the syntax of this problem
 
Hello, (e-mail address removed)!

the text after '?' is referred to as querystring.
In asp.net page to access query string you can use HttpRequest class.
The code can be like this

//Page_Load

string var = this.Request.QueryString["mid"];
int midVal;
if ( var != null && vat.Length > 0 )
{
if (!int.TryParse(var, out midVal) )
{
//report error
}
}

g> I am freelancer and designing a .net page.

g> I require the syntax in C# for capturing the variable from carryover
g> line in url eg: www.xyz.com/ccc.aspx?mid=12

g> how to capture this mid in c# and I have to use in my sql string
g> along
g> with Select * from Tbname where mid = 12.

g> can yu pls help me with the syntax of this problem


--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
As you say you are a freelancer, I will assume you have at least some
programming background. As such, the best thing would really be to look at
the numerous aspnet examples on MSDN or google...

How about: http://aspnet101.com/aspnet101/tutorials.aspx?id=29 titled
""Using Querystrings From Page to Page Then using them in your SQL
statement". I haven't read it, but it sounds promising...

Marc
 
And yes the language is VB, but the C# / VB conversion should not be an
issue.

Marc
 
Hi vadym
Thanks for all info, however here is my code ::::

string var = this.Request.QueryString["midcateid"];
// replace the database connection information here with
your own login information
SqlConnection conn = new
SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionInfo"]);
SqlCommand comm = new SqlCommand("SELECT DISTINCT hdetails
FROM Hofftable",conn);
SqlDataReader dr;

I have used the query string to bring the record autoid from prev page
and it is a numeric value. so if I capture it as a string, wont id give
me a problem while adding in my SQL cmd ie..

SELECT DISTINCT hdetails FROM Hofftable Where adminlock = 1 AND autoid
=" + var,conn);

?????

pls help

regrds
 
Thanks a lot my friend....I solved the problem on my end...
But another 1 has occurred....
This time I was trying to send the mail in MHML format with C# code
It is very easy in classic asp but what i find in .net(C#) it seems to
be a tedious one....
can yu help me with the code pls..

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top