显示标签为“row”的博文。显示所有博文
显示标签为“row”的博文。显示所有博文

2012年3月29日星期四

Display 1 piece of Data from a SQLDataSource

I have the following sqlDataSource. I wan't to display one piece of data, not a whole row, from it. I can find lots of information on putting it into a datagrid, but nothing on puttin one piece in a textbox. I cannot use a formview as we are embedding html in response.write and it breaks in a formview. Thanks.

<asp:SqlDataSourcerunat="server"

ID="myEmpInfo"

SelectCommand="Select di.EmpInfo,di.eth,gc.t_level

From tblEmp di

,tblMisc gc

Where di.empnum = @.empnum

and di.empnum = gc.empnum"DataSourceMode="DataReader"ConnectionString="<%$ ConnectionStrings : myConnectionString %>">

<SelectParameters>

<asp:QueryStringParameterName="empnum"QueryStringField="empnum"/>

</SelectParameters>

</asp:SqlDataSource>

Hi,

Do you want to get the value of specific row and specific column from a table? If so,you can use DataView to achieve. See the following sample:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" DataSourceMode="DataSet" ConnectionString="<%$ ConnectionStrings:TestConnectionString2%>" ></asp:SqlDataSource>
SqlDataSource1.SelectCommand ="select CategoryName from Categories";DataView dw = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
 
/// Display all the valueforeach (DataRow drin dw.Table.Rows) {foreach (DataColumn dcin dw.Table.Columns) { Response.Write(dr[dc.ToString()].ToString() +";"); } Response.Write("\r\n"); }/// You also can use /// string str = dw.Table.Rows[0][0].ToString(); /// to get the value from a specific row specific column.
Hope that helps. Thanks.

2012年3月19日星期一

disconnect a user whoz locking the DB with diff SPIDs

I have issued a simple insert statement on table and the statement could not insert a single row into the table.When i check the locks on the tables i found that almost 5000(five thousand) locks on the table for a single user with different SPID(s).
The user is and sql server user(not a windows user) and used to connect to the application.I wanted to disconnect the user from the DB so that all the locks will be freed.But i dunno how to disconnect a user from the DB. I know that i can issue KILL command to Terminate a user process based on the system process ID,but here the same user has nearly 1000 SPIDs.I thought that it would be very big job to kill each and every process and restared the sql server.but i guess its not the correct process to do.
how can i dosconnect a specific user from the DB.

Thanks.Well if you think it's a big job to kill 1,000 spids, how big of a job is it to create them?

I would want to know what process is soing that.

Also, watch the ROLLBACK...it'll be twice as long as letting the work COMMIT

But you've got bigger problems...

ALTER DATABASE <database> SET SINGLE_USER WITH ROLLBACK IMMEDIATE

Will blow everyone out, rollback all uncommitted work, and give you control

2012年3月7日星期三

Disappearing Measures?

Not sure what I could have done to make this happen ... but one of my simple measures (simply a row count of my fact table) no longer shows a value EXCEPT when I use it with one of my multi-level hierarchies I defined.

Has anyone seen this?

Is there a way to fix it?

I really have no idea what I coulda done. I've even commented out my calculated members and removed any non-regular dimensions and it still ain't working.

Thanks - WaydeDoes your calculations script contain a CALCULATE command? Without this no aggregation will be done and only the leaf cells will contain data.

2012年2月24日星期五

Disabled the automatic round of SQL SERVER 2000 on the float data type

Hello,

I have a problem with the round of SQL Server 2K on the float data type.

In my application I do a SQL request for find a row in a table of SQL Server 2K.

This is the request :

SELECT DISTINCT N_ROW_ID FROM COMM WHERE N_ARTICLE_ID=79510 AND N_DATASOURCE_ID=1 AND N_SOURCE_ID=-102 AND N_PROVIDER_ID=-100
AND N_LEAD_TIME IS NULL AND N_UNIT_PRICE = 329.78 AND N_UNIT_PRICE_CURRENCY_ID=1

N_UNIT_PRICE is a float data type.

In the line need, the field N_UNIT_PRICE has 329.78 but with the round of SQL Server 2K I have 329.779999999999997.

So I never find the row

Do you have a solution for comparate a float flied with SQL Server round and a float send in a request as my 329.78?

I can't transform the column in decimal or numeric data type.

Is it possible to Disable the function?

Regards

Floats are known as inexact or approximate datatypes. Due to the 'fuzzy' rounding, the same value may display slightly different every time you look at it.

Floats are not appropriate for any situation where you will have to search or index the value.

If your N_UNIT_PRICE is a float, you 'could' convert it to a decimal in the query. For example, this may work:

Code Snippet


SELECT DISTINCT
N_ROW_ID
FROM COMM
WHERE ( N_ARTICLE_ID = 79510
AND N_DATASOURCE_ID = 1
AND N_SOURCE_ID = -102
AND N_PROVIDER_ID = -100
AND N_LEAD_TIME IS NULL
AND cast( N_UNIT_PRICE AS decimal(10,2)) = 329.78
AND N_UNIT_PRICE_CURRENCY_ID = 1
)

|||As Arnie described this is no "function" as you mentioned, float datatypes only provide exact precision as you defined it on the column. The precision "floats" on the size of the value.

Jens K. Suessmeyer.

http://www.sqlserver2005.de