Click here to Skip to main content
16,021,293 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
my query string is....\mypage.asp?q="Name=Ram|Email=ram@yahoo.com|Mobile=123456789|Address=sdfsg"
here i want to split it.As like- Name=Ram,Email=ram@yahoo.com...etc,and here,I want to insert this values in database field like Name,Email...etc.Here also query string may be varied.Please tell me
solution ,here i want to insert values in pageload event of .asp page not .aspx page.


please give me insertion code for insert value in sql server database.from .asp page.
Posted

You can use String.Split[^] to split the input based on the delimiter. This will give a string array where you will find the idividual elements.

However, if the amount pf fields may vary in your input string, how are you going to know which field is which?

Anyhow, after you have splitted the string, you can build up a SqlCommand[^], define SqlParameters[^] and the use the ExecuteNonQuery method to insert the data into the database.

The insert statement would look something like:
SQL
INSERT INTO TableNamw (Name, Email, ...)
VALUES (@name, @email, ...)

where @... will be the parameters where you define the values to insert from the string array.

To define the parameters and the values you can use SqlParameterCollection.AddWithValue[^] method
 
Share this answer
 
Comments
Mehdi Gholam 10-Sep-11 1:21am    
My 5!
i dont know exactly but i think it helps you

first get the query string value
then use string.split('|')
like
string [] variable=yourquerystring.split('|');
 
Share this answer
 
use this.

"Inventory Reports/CRSalesInvoice.aspx?" + "&Name=" + "Ram" + "&Email=" + "ram@yahoo.com"


and access name and email query string on another form as follow.

string Name;
Name = Request.QueryString["Name"];
string Email;
Email = Request.QueryString["Email"];



Yogesh Pednekar.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900