Showing posts with label dynamic. Show all posts
Showing posts with label dynamic. Show all posts

Friday, March 30, 2012

How to insert the value from the text box (ASP.NET 2.0) to the microsoft sql server 2000 d

Hello Friends,

I have a problem with ASP.net with dynamic data transfer from asp page to microsoft sql server 2000. For example , I have asp web page with one text field and a buttion.When I click the buttion, the value entered in the text field should be transfered from the text field to database.

Kindly See the following section c# code ....

SqlConnection objconnect = new SqlConnection(connectionString);

SqlCommand cmd = new SqlCommand();

cmd.Connection = objconnect;

cmd.CommandText = " select * from Table_Age where Age = @.Age";

cmd.CommandType = CommandType.Text;

SqlParameter parameter = new SqlParameter();

parameter.ParameterName = "@.Age";

parameter.SqlDbType = SqlDbType.VarChar;

parameter.Direction = ParameterDirection.Output;

parameter.Value = TextBox1.Text;

objconnect.Open();

// Add the parameter to the Parameters collection.

cmd.Parameters.Add(parameter);

SqlDataReader reader = cmd.ExecuteReader();

********************this section c# code is entered under the button control************************************

connection string is mentioned in the web.config file.

In the above c# code , I have a text field , where I entered the age , the value entered in the text field should be sent to database. I have used SqlParameter for selecting the type of data should be sent from ASP.NET 2.0 to the microsoft sql server 2000. I am facing a problem where I am unable to sent the random datas from a text field to the database server.I have a created a database file in the microsoft server 2000.

after the excution of the fIeld value is assinged to NULL in the main database i.e microsoft the sql server 2000.

Can anyone help with this issue.

My mail id phijop@.hotmail.com

- PHIJO MATHEW PHILIP.

Hi

Remove :

parameter.Direction = ParameterDirection.Output;

since your direction should be input.

Wednesday, March 28, 2012

How to insert data into table varialable in a sp from dynamic table

In my sp,I want to get some data from a table which name is dynamic
,and insert the data to a table varialbe,in other words,look like
below:
StoredProcedure
(
DECLARE @.TABLENAME VARCHAR(255)
DECLARE @.MyTABLE TABLE (ID INT,NAME VARCHAR(255),AGE INT)
INSERT INTO
@.MyTABLE
SELECT
ID,
NAME,
AGE
FROM
@.TABELNAME
)
how to do this?thanksJohn
Well you are goimg to use dynamic sql, try this
declare @.t varchar(10)
set @.t ='Orders'
exec('declare @.table table (col1 int)
insert into @.table select orderid from '+ @.t+'
select * from @.table')
Note ; a declaration of the table variable must be in the scope of the EXEC
command, I'd consider using
sp_executesql system stored procedure
See an example
declare @.sql nvarchar(1000),
@.col sysname,
@.orderid int
select @.col='OrderID', @.orderid=10248
set @.sql = 'select * from Northwind..Orders where '+@.col+'= @.ordid'
exec sp_executesql @.sql, N'@.ordid int',@.orderid
"John Smith" <debussy@.gmail.com> wrote in message
news:1135220972.346999.221580@.o13g2000cwo.googlegroups.com...
> In my sp,I want to get some data from a table which name is dynamic
> ,and insert the data to a table varialbe,in other words,look like
> below:
> StoredProcedure
> (
> DECLARE @.TABLENAME VARCHAR(255)
> DECLARE @.MyTABLE TABLE (ID INT,NAME VARCHAR(255),AGE INT)
> INSERT INTO
> @.MyTABLE
> SELECT
> ID,
> NAME,
> AGE
> FROM
> @.TABELNAME
> )
> how to do this?thanks
>|||I want to returun the table variable as a result set at the end of
stored procedure,your way just insert it to a table variable in a short
scope,can't return to outside,anyway,still need to say thanks to you.
StoredProcedure
(
DECLARE @.TABLENAME VARCHAR(255)
DECLARE @.MyTABLE TABLE (ID INT,NAME VARCHAR(255),AGE INT)
INSERT INTO
@.MyTABLE
SELECT
ID,
NAME,
AGE
FROM
@.TABELNAME
SELECT
ID,
NAME,
AGE
FROM
@.MyTable
)|||I have to use tempoary table to solve this problem

Monday, March 19, 2012

How to improve report performance

Hi,
I have created reports in CRXI with Dynamic & Cascading Prompt. My reports are taking long time 15-20 mins to refressh.
Can sombdy help me to improve my reports performance ?Can Sombdy help me?|||Can anybdy answer this question|||how many records is it selecting? it shows you in the bottom right corner|||When I run the foolowing Query. It runs fine & gives 199 records

SELECT distinct clients.uid,max(da_answer.date_effective) as date,entry_exit.provider_id as provider,
datediff(yyyy,da_answer_val_unsec.val_date,getdate()) as age,
convert(varchar,DATEDIFF ( yyyy,val_date, getdate())) vage,
Case
when DATEDIFF ( yyyy,val_date, getdate()) between 5 and 12 then '5-12'
when datediff(yyyy,val_date,getdate()) between 13 and 17 then '13-17'
when datediff(yyyy,val_date,getdate()) between 18 and 44 then '18-44'
when datediff(yyyy,val_date,getdate()) between 45 and 64 then '45-64'
else 'Over 65'
end as Agegroup

FROM (((clients INNER JOIN da_answer ON clients.uid=da_answer.client_id) INNER JOIN
(da_assessment_question INNER JOIN da_question ON
da_assessment_question.question_id=da_question.uid) ON
da_answer.question_id=da_question.uid) INNER JOIN entry_exit ON
da_answer.client_id=entry_exit.client_id) INNER JOIN da_answer_val_unsec ON da_answer.uid=da_answer_val_unsec.answer_id

WHERE da_answer.date_effective IN( select date_effective FROM da_answer a
WHERE date_effective = (select max(b.date_effective)
FROM da_answer b WHERE b.uid=a.uid) and da_question.uid=893 AND clients.inactive=0 AND
da_assessment_question.assessment_id=21 AND entry_exit.inactive=0)
AND
(((entry_exit.entry_date IS NOT NULL)
AND
(entry_exit.entry_date>={ts '2005-01-01 00:00:00'} AND
entry_exit.entry_date<={ts '2005-03-31 23:59:00'})) and
((entry_exit.exit_date is null) or not
((entry_exit.exit_date >{ts '2004-07-01 00:00:00'} and entry_exit.exit_date <{ts
'2004-12-31 23:59:00'}))))
group by clients.uid,da_answer_val_unsec.val_date,entry_exit.provider_id

After this query I got the clients who have same date_effective but I need distinct clients with max(date_effective) so I create the above query as view(AGE) & applied the following query to this view

select a.uid,a.agegroup,a.provider
from age a
where date in(select max(b.date)
from age b
where a.uid=b.uid
group by uid)
order by a.uid
This query takes 10-15mins to run in sql designer & gives 192 records.|||Have you analysed the execution of your query. It seems that the query optimizer in your DBMS does not work properly when you make the query using the view. Check the plan and make sure query uses indexes and does not perform full table joins.

- Jukka|||Hi

My performance problem is caused by ineffiecient generated HTML - for each item in the reports' table a <DIV><TABLE><TR><TD><TABLE><TR><TD> is generated (??!!) hard to believe !!

Multiply this by a few thousand items to be displayed and you've got a catastrophe.

How can I work around this ??

Thanks

David|||The HTML generated by Crystal is really ugly. We have worked around it by using the pdf format.

Sunday, February 19, 2012

How to hide/show parameter dynamic?

There is a date range parameter in my rdl, the list value is "This Week","This Month", "This Year" and "Custom", when user choose "Custom", then display two parameter "Date From" and "Date To" to select custom date range.

My question, how to show "Date From" and "Date To" when user choose "Custom", and will hide these two parameter when user choose other item.

Thanks

You don't say what kind of element Date To and Date From are, but if they are text boxes with lables, you can change their Visible property from "False" to "True" or vice versa, depending on what the user has selected. I suggest that the default poroperty should be False., then make them Visisble if the user chooses "Custom"|||

Thanks for you reply

But the parameter's visible property cannot support formula, and I cannot get the change event of parameter "Date Range", such as selectedIndexChange

I use SRS2005, the "Date Range" is a dropdownlist, "Date From" and "Date To" may be the text box

How to hide/show parameter dynamic?

There is a date range parameter in my rdl, the list value is "This
Week","This Month", "This Year" and "Custom", when user choose "Custom", then
display two parameter "Date From" and "Date To" to select custom date range.
My question, how to show "Date From" and "Date To" when user choose
"Custom", and will hide these two parameters when user choose other item.
I use SRS2005
If cannot design the above function, I want to know, how to set the layout
of 3 parameters as:
Date Range ______
Date From ______ Date To ______
The SRS will display as:
Date Range ______ Date From ______
Date To ______
ThanksIf the parameters values are coming from query byway of datasets then it can
be cascaded so whn you select "custom" then it displayes the from and to
otherwise I suppose it is not possible. when you create 3 parameters then it
displays all 3.
Amarnath
"icyer" wrote:
> There is a date range parameter in my rdl, the list value is "This
> Week","This Month", "This Year" and "Custom", when user choose "Custom", then
> display two parameter "Date From" and "Date To" to select custom date range.
> My question, how to show "Date From" and "Date To" when user choose
> "Custom", and will hide these two parameters when user choose other item.
> I use SRS2005
> If cannot design the above function, I want to know, how to set the layout
> of 3 parameters as:
> Date Range ______
> Date From ______ Date To ______
> The SRS will display as:
> Date Range ______ Date From ______
> Date To ______
> Thanks
>|||Hi
I'd be curious as to your coding behind this. I need to do similar in
giving a list that has predefined dates to be passed except when the user
chooses their own dates.
Thanks
chelle
"icyer" wrote:
> There is a date range parameter in my rdl, the list value is "This
> Week","This Month", "This Year" and "Custom", when user choose "Custom", then
> display two parameter "Date From" and "Date To" to select custom date range.
> My question, how to show "Date From" and "Date To" when user choose
> "Custom", and will hide these two parameters when user choose other item.
> I use SRS2005
> If cannot design the above function, I want to know, how to set the layout
> of 3 parameters as:
> Date Range ______
> Date From ______ Date To ______
> The SRS will display as:
> Date Range ______ Date From ______
> Date To ______
> Thanks
>