Showing posts with label answers. Show all posts
Showing posts with label answers. Show all posts

Tuesday, March 27, 2012

Binding a Text Box to a datasoure - Please help

I have search for answers to the all over google and every thing I have found so far did not work for some reason or anothr. .

Here is what I am looking for I am codeing in Visual Studio using C#. I have been able to crate a connection and create taxt boxes with a submit button that when it is presed enters data in to a database (Sql server) what I have been unable to do is:

1. Display data in a text box.

2. Update data

3. create buttons to navagate through fields.

I know I can do this with the gridview or datagrid but in really need a custome form for what I am doing.

Hello,

You can use a Sqldatasource to do insert, update and delete for your textboxes. You can read the data from datasource through a datareader object and bind the data you your textboxes manually. For example, txtComments.Text =Convert.ToString(dReader["Comments"]).

You can call Sqldatsource.update() to update your form data when your tesxboxes' values have been changed.

You can create a linkbutton to send in some sort of id to the page on its click event to retrieve data for these textboxes.

Or you can do everything from code behind as in ASP.NET 1.X programmatically.

If you have more questions, please post back.

Friday, February 10, 2012

Best use of Indexing and Clustering

I am afraid I am here again with a problem (I seem to create more help
requests than answers these days). I have the following table (which is not
my design!).
[Messagetpye] [varchar] (50) NULL ,
[Sourcetype] [varchar] (50) NULL ,
[CallID] [varchar] (50) NULL ,
[Devicetype] [varchar] (50) NULL ,
[DeviceID] [varchar] (50) NULL ,
[Starttimestamp] [datetime] NOT NULL ,
[Direction] [varchar] (50) NULL ,
[AdvisorID] [varchar] (50) NULL ,
[CustomerID] [varchar] (50) NULL ,
[ActivityID] [varchar] (50) NULL ,
[AuditTrail] [varchar] (8000) NULL
I have set Indexing on
StartTimeStamp as Clustered
AdvisorID
CustomerID
ActivityID
If I do a simple SQL Statement like.
select top 100 * from tbl_audittrail where advisorid like '%LH%'
I get a 10 second response and 97% cost on the index scanning 390,610
however if I do..
select top 50 * from tbl_audittrail where advisorid like '%LH%' and
starttimestamp >'03 august 2007'
I get a 120 second response and 97% cost on the index scanning 4,325,334
Is there any way to configure this in a better way to get a quicker response
on the 2nd Query as the web front end I have build always has to use the
starttimestamp along with one of the indexed fields in its searches.
Any help is greatly appreciated.
Stumpy
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200709/1Hi
First of all what is the version are you using? It is important because MS
has added in SQL Server 2005 INCLUDE operator for indexes, see BOL
Secondly, what kind of indexes you are created? Is it Clustered or
NonClusterd?
> select top 100 * from tbl_audittrail where advisorid like '%LH%'
Don't use TOP clause without specify ORDER BY clause as you may geg
unordered result. Moreover , with the above query SQL Server will not use an
index as you provide '%%' .Do you really need to return all columns? What if
you run
SELECT AdvisorID,CustomerID FROM tbl WHERE advisorid like 'LH%' ,does it
run faster?
> select top 50 * from tbl_audittrail where advisorid like '%LH%' and
> starttimestamp >'03 august 2007'
Again , do you have an index on starttimestamp ? If you do try run this
query as
select top 50 * from tbl_audittrail where advisorid like '%LH%' and
starttimestamp >='20070803' AND starttimestamp < DATEADD(d,1,getdate())
ORDER BY .....
"stumpy_uk via SQLMonster.com" <u15773@.uwe> wrote in message
news:77c0b1470e597@.uwe...
>I am afraid I am here again with a problem (I seem to create more help
> requests than answers these days). I have the following table (which is
> not
> my design!).
> [Messagetpye] [varchar] (50) NULL ,
> [Sourcetype] [varchar] (50) NULL ,
> [CallID] [varchar] (50) NULL ,
> [Devicetype] [varchar] (50) NULL ,
> [DeviceID] [varchar] (50) NULL ,
> [Starttimestamp] [datetime] NOT NULL ,
> [Direction] [varchar] (50) NULL ,
> [AdvisorID] [varchar] (50) NULL ,
> [CustomerID] [varchar] (50) NULL ,
> [ActivityID] [varchar] (50) NULL ,
> [AuditTrail] [varchar] (8000) NULL
> I have set Indexing on
> StartTimeStamp as Clustered
> AdvisorID
> CustomerID
> ActivityID
> If I do a simple SQL Statement like.
> select top 100 * from tbl_audittrail where advisorid like '%LH%'
> I get a 10 second response and 97% cost on the index scanning 390,610
> however if I do..
> select top 50 * from tbl_audittrail where advisorid like '%LH%' and
> starttimestamp >'03 august 2007'
> I get a 120 second response and 97% cost on the index scanning 4,325,334
> Is there any way to configure this in a better way to get a quicker
> response
> on the 2nd Query as the web front end I have build always has to use the
> starttimestamp along with one of the indexed fields in its searches.
> Any help is greatly appreciated.
> Stumpy
> --
> Message posted via SQLMonster.com
> http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200709/1
>|||Uri Dimant wrote:
>Hi
>First of all what is the version are you using? It is important because MS
>has added in SQL Server 2005 INCLUDE operator for indexes, see BOL
>Secondly, what kind of indexes you are created? Is it Clustered or
>NonClusterd?
>> select top 100 * from tbl_audittrail where advisorid like '%LH%'
>Don't use TOP clause without specify ORDER BY clause as you may geg
>unordered result. Moreover , with the above query SQL Server will not use an
>index as you provide '%%' .Do you really need to return all columns? What if
>you run
>SELECT AdvisorID,CustomerID FROM tbl WHERE advisorid like 'LH%' ,does it
>run faster?
>> select top 50 * from tbl_audittrail where advisorid like '%LH%' and
>> starttimestamp >'03 august 2007'
>Again , do you have an index on starttimestamp ? If you do try run this
>query as
> select top 50 * from tbl_audittrail where advisorid like '%LH%' and
> starttimestamp >='20070803' AND starttimestamp < DATEADD(d,1,getdate())
>ORDER BY .....
>>I am afraid I am here again with a problem (I seem to create more help
>> requests than answers these days). I have the following table (which is
>[quoted text clipped - 39 lines]
>> Stumpy
Uri,
Its SQL 2000 and the datetime was a Clustered Index.
However you have answered my question as soon as I took the * Away and added
the order by its 0 - 5 seconds for each of the queries...thanks again for all
your help
Cheers
Lee
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200709/1