Saturday, February 25, 2012

Data access in a variable

Hello Friends

i have one problem, i have to need fatch the data from database .

in the web form i take three grid view and i put the query "Select Top 1 coloum1 from tanlename order by newid()" .

when the data came from database there is no sequence series . so i want to take fatch the data from database in variable like int a , b , c and call the data in those variable

and put up in the feild

example :- welcome to Mr "Data call from data base (1) " how are you "Data call from data base (2)" bbye and "Data call from data base (3)"

Answer "- welcome to Mr "ASHWANI" how are you FINE OR NOT" bbye and "TAKE CARE"

there is all capslock on value came from databse and these value in the web page store in a variable

like int a ;

int b;

int c;

please help me please i have a huge problem

Ashwnai

Hi ashwani2kumar,

Not 100% sure what you mean. How do you fetch those data from your database? what does you select query look like?

welcome to Mr "Data call from data base (1) " how are you "Data call from data base (2)" bbye and "Data call from data base (3)"

Answer "- welcome to Mr "ASHWANI" how are you FINE OR NOT" bbye and "TAKE CARE"

If your string is fixed, i mean, those "welcoem to, how are you ..etc" stuff are fixed, i think you can assemble that string within a stored procedure, like this:

create procedure sp_string par1_defination,par2_defination,// i don't know how do you fetch those data, so, fill in those query parameters by yourself@.ret_str varchar(200) outputasdeclare @.str1 varchar(20),@.str2 varchar(20),@.str3 varchar(30)select @.str1=Namefrom table1 where// your query 1select @.str2=colnamefrom table2 where// your query 2select @.str3=colnamefrom table3 where// your query 3set @.ret_str='welcome to Mr'+@.str1+'how are you'+@.str2+'bbye and'+@.str3return
Hope my suggestion helps

No comments:

Post a Comment