Showing posts with label grid. Show all posts
Showing posts with label grid. Show all posts

Sunday, February 19, 2012

Gridview refresh after update

Hi All,

I am new to development of asp. I have an SQLDataSource set as the data source for a grid view. When I click on the edit link in the Gridview, change the data, and click update, the old data is still displayed in the row.

I found exact same issue as here --http://forums.asp.net/thread/1217014.aspx

Solution in the above thread is to add this

{
if (reader != null) reader.Close();
}
conn.Close();

How do I apply above solution in my situation ?

I am updating through stored procedure.and don't have code at background. My code is

Datasource :

<

asp:SqlDataSourceID="ds"runat="server"ConnectionString="<%$ ConnectionStrings:ds %>"

CancelSelectOnNullParameter="False"ProviderName="<%$ ConnectionStrings:ds.ProviderName%>"UpdateCommand="usp_save"UpdateCommandType="StoredProcedure"EnableCaching="False">

<UpdateParameters>

<asp:ParameterName="field1"Type="String"/><asp:ParameterName="field2"Type="String"/><asp:ParameterName="field3"Type="String"/><asp:ParameterName="field4"Type="String"/><asp:ControlParameterName="field5"Type="String"ControlID="label7"/></UpdateParameters>

Anyone Please ?? Help me with this . I am still not able to find the solution.

Thanks in advacne

|||Where is your select statement?|||

Thanks for the reply .

I do select also using stored procedure. I can post stored procedure code if needed.

Here is the full sqldatasource and function

<asp:SqlDataSource
ID="idpl"
runat="server"
ConnectionString="<%$ ConnectionStrings:idpl %>"
SelectCommand="sp_Mapping"
SelectCommandType="StoredProcedure"
CancelSelectOnNullParameter="False"
ProviderName="<%$ ConnectionStrings:idpl.ProviderName%>"
UpdateCommand="sp_SaveMapping"
UpdateCommandType="StoredProcedure"
OnUpdating="pnl_Updating" EnableCaching="False">
<SelectParameters>
<asp:ControlParameter ControlID="Txt1" Name="OriginalID" Type="String" PropertyName="Text" DefaultValue="" />
<asp:ControlParameter ControlID="Txt2" Name="Name" Type="String" PropertyName="Text" DefaultValue="" />
<asp:ControlParameter ControlID="DDL" Name="sName" Type="String" DefaultValue="None" PropertyName="SelectedValue" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="OriginalID" Type="String" />
<asp:Parameter Name="sName" Type="String" />
<asp:Parameter Name="PartNum" Type="String" />
<asp:Parameter Name="plantName" Type="String"/>
<asp:ControlParameter Name="userID" Type="String" ControlID = "label7" />
</UpdateParameters>
</asp:SqlDataSource>

protected void pnl_Updating(object sender, SqlDataSourceCommandEventArgs e)
{
DbParameterCollection CmdParams = e.Command.Parameters;
ParameterCollection UpdParams = ((SqlDataSourceView)sender).UpdateParameters;

Hashtable ht = new Hashtable();
foreach (Parameter UpdParam in UpdParams)
ht.Add(UpdParam.Name, true);

for (int i = 0; i < CmdParams.Count; i++)
{
if (!ht.Contains(CmdParams[i].ParameterName.Substring(1)))
CmdParams.Remove(CmdParams[i--]);
}

}

|||

Does the database values change?

If no, then the update isn't happening correctly, use the sql profiler to see what is being generated, and why it is failing to update correctly.

If yes, then in the sqldatasource's Updated event, add a gridview.databind and see if that resolves your problem. If it does not, place a breakpoint in the sqldatasource's Selecting event, and make sure that it is getting called after an update.

|||

Yes .. Database value changes.So stored procedure is definitely working.

I'll try to follow your suggestions on updated event and update the post soon.

Thanks for your help.

|||

Hi Motley,

I followed your suggestion.

1. Added gridview.databind at "updated" event.

2. Applied the breakpoint and made sure that the even is getting fired.

Still having the same issue. Gridview still shows two rows. Old and newly updated.

Any more pointers will be greatly appreciated.

Thanks

|||

Not sure if your problem is fixed or not. Sounds like your update statement has truncated to an insert statement. Have you looked into make sure it is pulling the PK of the table that singularly references the field you are looking for?

GridLines problem when exporting a report to excel

1,
I have a report when I export it to excel it exported successfully.
But when I open the report the grid lines are gone.
I have to manually enable grid lines to view them.
How Can I export the file to excel such that grid line will be enable

2,Currently I am checking the export to excel via report manager.
What should be the url to export to excel.

Hello Kamii,

#1. Can you verify that your BorderColor is not set to White and your BorderStyle is set to Solid on your textboxes in your report?

#2. Here's the example MS had, but changed to Excel: http://servername/reportserver?/Sales/YearlySalesSummary&rs:Format=EXCEL&rs:Command=Render

This link explains the URL export. http://msdn2.microsoft.com/en-us/library/ms154040.aspx
Here's another link for Using URL Access Parameters: http://msdn2.microsoft.com/en-us/library/ms152835.aspx

Hope this helps.

Jarret

|||Thanks Jarret
I have one more question


3,
We have predefined excel tempaltes
I have a excel report with on main worksheet all data then on other work sheet data based on first work sheet with pivot table.
We were generating with old vb6 application.
Now I want's to use SSRS to generate report then export it to excel as my previous template.Can i do that ?

I know it is an odd idea by the client but we have to implement it
Can you please refer me from where i can find help regarding this ?
|||

I don't think this will be possible with Reporting Services. Here are a few posts from others that are wanting to use templates as well.

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=519081&SiteID=1
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=461709&SiteID=1

The second link above mentions a third party tool that looks like it will do what you need.

http://officewriter.softartisans.com/officewriter-250.aspx

Jarret

Grid vs Text output

In SQL Query Analyzer, there is a Query drop down window that gives you
the option to change the output from grid to text for printing if
needed. My question is, can this be programmed so a stored procedure
will always print in text without having to manually change the window
each time the procedure is run? I could find nothing under the logical
searches in books online.

Thanks JABYou can modify the QA to use text or use a grid regardless what you are
running in the QA. You can't set default behavior for each object or
each type of object.

Adi
jab wrote:

Quote:

Originally Posted by

In SQL Query Analyzer, there is a Query drop down window that gives you
the option to change the output from grid to text for printing if
needed. My question is, can this be programmed so a stored procedure
will always print in text without having to manually change the window
each time the procedure is run? I could find nothing under the logical
searches in books online.
>
Thanks JAB

Grid view-cant update or delete

I put a grid view on a web form ,when I run it -the SELECT, EDIT works

the UPDATE,DELETE makes an error although I use the sama data,I added the error :

Anyone can help?

Server Error in '/CrystalReportsWebSite1' Application.

The data types text and nvarchar are incompatible in the equal to operator.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.Data.SqlClient.SqlException: The data types text and nvarchar are incompatible in the equal to operator.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[SqlException (0x80131904): The data types text and nvarchar are incompatible in the equal to operator.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +95 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +82 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +346 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +3244 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +186 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1121 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +334 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +407 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +149 System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +493 System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +915 System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +179 System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +1140

Hey,

What does those update/delete stored procedures look like? It seems like it may be an issue with the query.

|||I'm guessing he has a text field, and he told it to use optimistic concurrency or (CompareAllValues), which doesn't work with text fields.

Grid results in Management Studio

Hi
When I run a query in Management Studio, I get this message -
The query has exceeded the maximum number of result sets that can be
displayed in the results grid. Only the first 100 result sets are
displayed in the grid.
Is there any way to change this limit so I can get all results?
Regards
SteenWhich version are you using ? On SQL 2005 Ent. RTM version I don't have
this problem. I can select 1000000 rows and all are displayed in the
grid.
Markus|||Rows is not the same as resultsets. Steen has the problem that the query returns > 100 result sets.
AFAIK, this is not a configurable limit.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"MarkusB" <m.bohse@.quest-consultants.com> wrote in message
news:1132222959.738766.69660@.g47g2000cwa.googlegroups.com...
> Which version are you using ? On SQL 2005 Ent. RTM version I don't have
> this problem. I can select 1000000 rows and all are displayed in the
> grid.
> Markus
>|||Tibor Karaszi wrote:
> Rows is not the same as resultsets. Steen has the problem that the query returns > 100 result sets.
> AFAIK, this is not a configurable limit.
>
Thanks Tibor. It's not a major problem - it's just annoying when it
happens..;-). I've also looked around to see if I could find somewhere
where it could be configured but with no luck.
Regards
Steen

Grid results in Management Studio

Hi
When I run a query in Management Studio, I get this message -
The query has exceeded the maximum number of result sets that can be
displayed in the results grid. Only the first 100 result sets are
displayed in the grid.
Is there any way to change this limit so I can get all results?
Regards
Steen
Which version are you using ? On SQL 2005 Ent. RTM version I don't have
this problem. I can select 1000000 rows and all are displayed in the
grid.
Markus
|||Rows is not the same as resultsets. Steen has the problem that the query returns > 100 result sets.
AFAIK, this is not a configurable limit.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"MarkusB" <m.bohse@.quest-consultants.com> wrote in message
news:1132222959.738766.69660@.g47g2000cwa.googlegro ups.com...
> Which version are you using ? On SQL 2005 Ent. RTM version I don't have
> this problem. I can select 1000000 rows and all are displayed in the
> grid.
> Markus
>
|||Tibor Karaszi wrote:
> Rows is not the same as resultsets. Steen has the problem that the query returns > 100 result sets.
> AFAIK, this is not a configurable limit.
>
Thanks Tibor. It's not a major problem - it's just annoying when it
happens..;-). I've also looked around to see if I could find somewhere
where it could be configured but with no luck.
Regards
Steen

Grid results in Management Studio

Hi
When I run a query in Management Studio, I get this message -
The query has exceeded the maximum number of result sets that can be
displayed in the results grid. Only the first 100 result sets are
displayed in the grid.
Is there any way to change this limit so I can get all results?
Regards
SteenWhich version are you using ? On SQL 2005 Ent. RTM version I don't have
this problem. I can select 1000000 rows and all are displayed in the
grid.
Markus|||Rows is not the same as resultsets. Steen has the problem that the query ret
urns > 100 result sets.
AFAIK, this is not a configurable limit.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"MarkusB" <m.bohse@.quest-consultants.com> wrote in message
news:1132222959.738766.69660@.g47g2000cwa.googlegroups.com...
> Which version are you using ? On SQL 2005 Ent. RTM version I don't have
> this problem. I can select 1000000 rows and all are displayed in the
> grid.
> Markus
>|||Tibor Karaszi wrote:
> Rows is not the same as resultsets. Steen has the problem that the query r
eturns > 100 result sets.
> AFAIK, this is not a configurable limit.
>
Thanks Tibor. It's not a major problem - it's just annoying when it
happens..;-). I've also looked around to see if I could find somewhere
where it could be configured but with no luck.
Regards
Steen

Grid pane in the table in enterprise manager

HI
When you right click open table to return all rows, click on the "Show/Hide Grid pane" icon . When you click on any row the first column called "Column" a dropdown shows all the filed names of that particular table.
This feature used to work fine untill recently wherein when I click on the column, I don't get to see all the filed names but now it just shows TableName.* i.e. all columns.
This is the case when I try to create a view in enterprise manager also. When you add a table to create a view, I cannot see all the filed names . I'm not sure what to do , to get the field names to appear? Is it some kind of setting in enterprise manager.
All the info would be appreciated.
Ta
NStop using Enterprise Manager (EM) and start using Query Analyzer (QA)

My own opinion

MOO

EM tends be quirky...|||I do use the Query analyser more than the EM, but it's just a functionality would reappear in the EM. Ta

Grid mode, Query Analyzer

Hi,
Does anyone know how to force Query Analyzer in Grid mode
to return results in chunks like it is in Text Mode? For
instance, when I have a query that returns results in a
loop, in Grid mode I would have to wait until the loop
exits to see the whole lot of them. With Text mode it's
different - I see results as I go.
Thanks,
Oskar
I do not think this is possible. Speaking as a developer, the grids in QA
auto adjusts their width taking into account the length of the header and
data, which would only be possible once you've loaded all the data into the
grid.
Peter Yeoh
http://www.yohz.com
Need smaller SQL2K backup files? Use MiniSQLBackup Lite, free!
"Oskar" <anonymous@.discussions.microsoft.com> wrote in message
news:086101c4b1b2$df5fd070$a401280a@.phx.gbl...
> Hi,
> Does anyone know how to force Query Analyzer in Grid mode
> to return results in chunks like it is in Text Mode? For
> instance, when I have a query that returns results in a
> loop, in Grid mode I would have to wait until the loop
> exits to see the whole lot of them. With Text mode it's
> different - I see results as I go.
> --
> Thanks,
> Oskar
>
|||I can't see a problem here: each result returned in a loop
has its own headers and data, the length of which should
be known. Maybe Query Analyzer just can't/won't read this
information during the execution?
Thanks,
Oskar

>--Original Message--
>I do not think this is possible. Speaking as a
developer, the grids in QA
>auto adjusts their width taking into account the length
of the header and
>data, which would only be possible once you've loaded all
the data into the
>grid.
>--
>Peter Yeoh
>http://www.yohz.com
>Need smaller SQL2K backup files? Use MiniSQLBackup Lite,
free!
>
>"Oskar" <anonymous@.discussions.microsoft.com> wrote in
message[vbcol=seagreen]
>news:086101c4b1b2$df5fd070$a401280a@.phx.gbl...
mode
>
>.
>
|||You mean there are multiple result sets returned? Then you're right, QA
(theoretically) should be able to display each result set as they come in.
Peter Yeoh
http://www.yohz.com
Need smaller SQL2K backup files? Use MiniSQLBackup Lite, free!
"Oskar" <anonymous@.discussions.microsoft.com> wrote in message
news:2de601c4b1c0$5c2592e0$a501280a@.phx.gbl...[vbcol=seagreen]
> I can't see a problem here: each result returned in a loop
> has its own headers and data, the length of which should
> be known. Maybe Query Analyzer just can't/won't read this
> information during the execution?
> --
> Thanks,
> Oskar
> developer, the grids in QA
> of the header and
> the data into the
> free!
> message
> mode
|||You're right, multiple result sets.

>--Original Message--
>You mean there are multiple result sets returned? Then
you're right, QA
>(theoretically) should be able to display each result set
as they come in.
>--
>Peter Yeoh
>http://www.yohz.com
>Need smaller SQL2K backup files? Use MiniSQLBackup Lite,
free!
>
>"Oskar" <anonymous@.discussions.microsoft.com> wrote in
message[vbcol=seagreen]
>news:2de601c4b1c0$5c2592e0$a501280a@.phx.gbl...
loop[vbcol=seagreen]
this[vbcol=seagreen]
all[vbcol=seagreen]
Lite,[vbcol=seagreen]
For[vbcol=seagreen]
in a[vbcol=seagreen]
loop[vbcol=seagreen]
it's
>
>.
>

Grid mode, Query Analyzer

Hi,
Does anyone know how to force Query Analyzer in Grid mode
to return results in chunks like it is in Text Mode? For
instance, when I have a query that returns results in a
loop, in Grid mode I would have to wait until the loop
exits to see the whole lot of them. With Text mode it's
different - I see results as I go.
Thanks,
OskarI do not think this is possible. Speaking as a developer, the grids in QA
auto adjusts their width taking into account the length of the header and
data, which would only be possible once you've loaded all the data into the
grid.
Peter Yeoh
http://www.yohz.com
Need smaller SQL2K backup files? Use MiniSQLBackup Lite, free!
"Oskar" <anonymous@.discussions.microsoft.com> wrote in message
news:086101c4b1b2$df5fd070$a401280a@.phx.gbl...
> Hi,
> Does anyone know how to force Query Analyzer in Grid mode
> to return results in chunks like it is in Text Mode? For
> instance, when I have a query that returns results in a
> loop, in Grid mode I would have to wait until the loop
> exits to see the whole lot of them. With Text mode it's
> different - I see results as I go.
> --
> Thanks,
> Oskar
>|||I can't see a problem here: each result returned in a loop
has its own headers and data, the length of which should
be known. Maybe Query Analyzer just can't/won't read this
information during the execution?
Thanks,
Oskar

>--Original Message--
>I do not think this is possible. Speaking as a
developer, the grids in QA
>auto adjusts their width taking into account the length
of the header and
>data, which would only be possible once you've loaded all
the data into the
>grid.
>--
>Peter Yeoh
>http://www.yohz.com
>Need smaller SQL2K backup files? Use MiniSQLBackup Lite,
free!
>
>"Oskar" <anonymous@.discussions.microsoft.com> wrote in
message
>news:086101c4b1b2$df5fd070$a401280a@.phx.gbl...
mode[vbcol=seagreen]
>
>.
>|||You mean there are multiple result sets returned? Then you're right, QA
(theoretically) should be able to display each result set as they come in.
Peter Yeoh
http://www.yohz.com
Need smaller SQL2K backup files? Use MiniSQLBackup Lite, free!
"Oskar" <anonymous@.discussions.microsoft.com> wrote in message
news:2de601c4b1c0$5c2592e0$a501280a@.phx.gbl...[vbcol=seagreen]
> I can't see a problem here: each result returned in a loop
> has its own headers and data, the length of which should
> be known. Maybe Query Analyzer just can't/won't read this
> information during the execution?
> --
> Thanks,
> Oskar
>
> developer, the grids in QA
> of the header and
> the data into the
> free!
> message
> mode|||You're right, multiple result sets.

>--Original Message--
>You mean there are multiple result sets returned? Then
you're right, QA
>(theoretically) should be able to display each result set
as they come in.
>--
>Peter Yeoh
>http://www.yohz.com
>Need smaller SQL2K backup files? Use MiniSQLBackup Lite,
free!
>
>"Oskar" <anonymous@.discussions.microsoft.com> wrote in
message
>news:2de601c4b1c0$5c2592e0$a501280a@.phx.gbl...
loop[vbcol=seagreen]
this[vbcol=seagreen]
all[vbcol=seagreen]
Lite,[vbcol=seagreen]
For[vbcol=seagreen]
in a[vbcol=seagreen]
loop[vbcol=seagreen]
it's[vbcol=seagreen]
>
>.
>

Grid mode, Query Analyzer

Hi,
Does anyone know how to force Query Analyzer in Grid mode
to return results in chunks like it is in Text Mode? For
instance, when I have a query that returns results in a
loop, in Grid mode I would have to wait until the loop
exits to see the whole lot of them. With Text mode it's
different - I see results as I go.
--
Thanks,
OskarI do not think this is possible. Speaking as a developer, the grids in QA
auto adjusts their width taking into account the length of the header and
data, which would only be possible once you've loaded all the data into the
grid.
--
Peter Yeoh
http://www.yohz.com
Need smaller SQL2K backup files? Use MiniSQLBackup Lite, free!
"Oskar" <anonymous@.discussions.microsoft.com> wrote in message
news:086101c4b1b2$df5fd070$a401280a@.phx.gbl...
> Hi,
> Does anyone know how to force Query Analyzer in Grid mode
> to return results in chunks like it is in Text Mode? For
> instance, when I have a query that returns results in a
> loop, in Grid mode I would have to wait until the loop
> exits to see the whole lot of them. With Text mode it's
> different - I see results as I go.
> --
> Thanks,
> Oskar
>|||I can't see a problem here: each result returned in a loop
has its own headers and data, the length of which should
be known. Maybe Query Analyzer just can't/won't read this
information during the execution?
--
Thanks,
Oskar
>--Original Message--
>I do not think this is possible. Speaking as a
developer, the grids in QA
>auto adjusts their width taking into account the length
of the header and
>data, which would only be possible once you've loaded all
the data into the
>grid.
>--
>Peter Yeoh
>http://www.yohz.com
>Need smaller SQL2K backup files? Use MiniSQLBackup Lite,
free!
>
>"Oskar" <anonymous@.discussions.microsoft.com> wrote in
message
>news:086101c4b1b2$df5fd070$a401280a@.phx.gbl...
>> Hi,
>> Does anyone know how to force Query Analyzer in Grid
mode
>> to return results in chunks like it is in Text Mode? For
>> instance, when I have a query that returns results in a
>> loop, in Grid mode I would have to wait until the loop
>> exits to see the whole lot of them. With Text mode it's
>> different - I see results as I go.
>> --
>> Thanks,
>> Oskar
>
>.
>|||You mean there are multiple result sets returned? Then you're right, QA
(theoretically) should be able to display each result set as they come in.
--
Peter Yeoh
http://www.yohz.com
Need smaller SQL2K backup files? Use MiniSQLBackup Lite, free!
"Oskar" <anonymous@.discussions.microsoft.com> wrote in message
news:2de601c4b1c0$5c2592e0$a501280a@.phx.gbl...
> I can't see a problem here: each result returned in a loop
> has its own headers and data, the length of which should
> be known. Maybe Query Analyzer just can't/won't read this
> information during the execution?
> --
> Thanks,
> Oskar
> >--Original Message--
> >I do not think this is possible. Speaking as a
> developer, the grids in QA
> >auto adjusts their width taking into account the length
> of the header and
> >data, which would only be possible once you've loaded all
> the data into the
> >grid.
> >
> >--
> >Peter Yeoh
> >http://www.yohz.com
> >Need smaller SQL2K backup files? Use MiniSQLBackup Lite,
> free!
> >
> >
> >"Oskar" <anonymous@.discussions.microsoft.com> wrote in
> message
> >news:086101c4b1b2$df5fd070$a401280a@.phx.gbl...
> >> Hi,
> >>
> >> Does anyone know how to force Query Analyzer in Grid
> mode
> >> to return results in chunks like it is in Text Mode? For
> >> instance, when I have a query that returns results in a
> >> loop, in Grid mode I would have to wait until the loop
> >> exits to see the whole lot of them. With Text mode it's
> >> different - I see results as I go.
> >>
> >> --
> >> Thanks,
> >> Oskar
> >>
> >
> >
> >.
> >|||You're right, multiple result sets.
>--Original Message--
>You mean there are multiple result sets returned? Then
you're right, QA
>(theoretically) should be able to display each result set
as they come in.
>--
>Peter Yeoh
>http://www.yohz.com
>Need smaller SQL2K backup files? Use MiniSQLBackup Lite,
free!
>
>"Oskar" <anonymous@.discussions.microsoft.com> wrote in
message
>news:2de601c4b1c0$5c2592e0$a501280a@.phx.gbl...
>> I can't see a problem here: each result returned in a
loop
>> has its own headers and data, the length of which should
>> be known. Maybe Query Analyzer just can't/won't read
this
>> information during the execution?
>> --
>> Thanks,
>> Oskar
>> >--Original Message--
>> >I do not think this is possible. Speaking as a
>> developer, the grids in QA
>> >auto adjusts their width taking into account the length
>> of the header and
>> >data, which would only be possible once you've loaded
all
>> the data into the
>> >grid.
>> >
>> >--
>> >Peter Yeoh
>> >http://www.yohz.com
>> >Need smaller SQL2K backup files? Use MiniSQLBackup
Lite,
>> free!
>> >
>> >
>> >"Oskar" <anonymous@.discussions.microsoft.com> wrote in
>> message
>> >news:086101c4b1b2$df5fd070$a401280a@.phx.gbl...
>> >> Hi,
>> >>
>> >> Does anyone know how to force Query Analyzer in Grid
>> mode
>> >> to return results in chunks like it is in Text Mode?
For
>> >> instance, when I have a query that returns results
in a
>> >> loop, in Grid mode I would have to wait until the
loop
>> >> exits to see the whole lot of them. With Text mode
it's
>> >> different - I see results as I go.
>> >>
>> >> --
>> >> Thanks,
>> >> Oskar
>> >>
>> >
>> >
>> >.
>> >
>
>.
>

Grid display

How would I take a bunch of records and make it display in a Grid Format
(actually going to go into a DataGrid) in one select statement - or can you?
If I have 12 records:
CREATE TABLE [dbo].[Rentals] (
[RentalID] [int] IDENTITY (1, 1) NOT NULL ,
[NumberOfDays] [int] NULL ,
[NumberOfRentals] [int] NULL ,
[RentalCost] [money] NULL
) ON [PRIMARY]
GO
insert Rentals (NumberOfDays,NumberOfRentals,RentalCost
) values (30,1,100)
insert Rentals (NumberOfDays,NumberOfRentals,RentalCost
) values (30,5,400)
insert Rentals (NumberOfDays,NumberOfRentals,RentalCost
) values (30,10,800)
insert Rentals (NumberOfDays,NumberOfRentals,RentalCost
) values (30,20,1600)
insert Rentals (NumberOfDays,NumberOfRentals,RentalCost
) values (60,1,175)
insert Rentals (NumberOfDays,NumberOfRentals,RentalCost
) values (60,5,700)
insert Rentals (NumberOfDays,NumberOfRentals,RentalCost
) values (60,10,1400)
insert Rentals (NumberOfDays,NumberOfRentals,RentalCost
) values (60,20,2800)
insert Rentals (NumberOfDays,NumberOfRentals,RentalCost
) values (90,1,225)
insert Rentals (NumberOfDays,NumberOfRentals,RentalCost
) values (90,5,900)
insert Rentals (NumberOfDays,NumberOfRentals,RentalCost
) values (90,10,1750)
insert Rentals (NumberOfDays,NumberOfRentals,RentalCost
) values (90,20,3500)
And I want it to display like so (with or without the headings) where the
number of days is in the parenthesis:
Type: Individual: Bundle (5) Bundle (10) Bundle (20)
30 Day $100 $400 $800 $1,600
60 Day $175 $700 $1,400 $2,800
90 Day $225 $900 $1,750 $3,500
The rows are grouped by days and the columns are ordered by NumberOfDays,
NumberOfRentals.
I could read them record by record and then place them into the grid, but I
would prefer to let the Select order it for me.
Thanks,
TomAs Tom says in a message a few hours ago, thanks for the DDL. It made it
easy to help you. Generally speaking it is usually suggested to do this in
the UI, not use SQL to manipulate the dat to fit the UI. On the other hand,
if you are talking small load it is fine to do it this way:
select numberOfDays,
sum(case when numberOfRentals = 1 then rentalCost else 0 end) as
Individual,
sum(case when numberOfRentals = 5 then rentalCost else 0 end) as
[Bundle(5)],
sum(case when numberOfRentals = 10 then rentalCost else 0 end) as
[Bundle(10)],
sum(case when numberOfRentals = 20 then rentalCost else 0 end) as
[Bundle(20)]
from rentals
group by numberOfDays
----
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"tshad" <tscheiderich@.ftsolutions.com> wrote in message
news:e8xikzRpFHA.1444@.tk2msftngp13.phx.gbl...
> How would I take a bunch of records and make it display in a Grid Format
> (actually going to go into a DataGrid) in one select statement - or can
> you?
> If I have 12 records:
> CREATE TABLE [dbo].[Rentals] (
> [RentalID] [int] IDENTITY (1, 1) NOT NULL ,
> [NumberOfDays] [int] NULL ,
> [NumberOfRentals] [int] NULL ,
> [RentalCost] [money] NULL
> ) ON [PRIMARY]
> GO
> insert Rentals (NumberOfDays,NumberOfRentals,RentalCost
) values (30,1,100)
> insert Rentals (NumberOfDays,NumberOfRentals,RentalCost
) values (30,5,400)
> insert Rentals (NumberOfDays,NumberOfRentals,RentalCost
) values
> (30,10,800)
> insert Rentals (NumberOfDays,NumberOfRentals,RentalCost
) values
> (30,20,1600)
> insert Rentals (NumberOfDays,NumberOfRentals,RentalCost
) values (60,1,175)
> insert Rentals (NumberOfDays,NumberOfRentals,RentalCost
) values (60,5,700)
> insert Rentals (NumberOfDays,NumberOfRentals,RentalCost
) values
> (60,10,1400)
> insert Rentals (NumberOfDays,NumberOfRentals,RentalCost
) values
> (60,20,2800)
> insert Rentals (NumberOfDays,NumberOfRentals,RentalCost
) values (90,1,225)
> insert Rentals (NumberOfDays,NumberOfRentals,RentalCost
) values (90,5,900)
> insert Rentals (NumberOfDays,NumberOfRentals,RentalCost
) values
> (90,10,1750)
> insert Rentals (NumberOfDays,NumberOfRentals,RentalCost
) values
> (90,20,3500)
> And I want it to display like so (with or without the headings) where the
> number of days is in the parenthesis:
> Type: Individual: Bundle (5) Bundle (10) Bundle (20)
> 30 Day $100 $400 $800 $1,600
> 60 Day $175 $700 $1,400 $2,800
> 90 Day $225 $900 $1,750 $3,500
> The rows are grouped by days and the columns are ordered by NumberOfDays,
> NumberOfRentals.
> I could read them record by record and then place them into the grid, but
> I would prefer to let the Select order it for me.
> Thanks,
> Tom
>|||"Louis Davidson" <dr_dontspamme_sql@.hotmail.com> wrote in message
news:OBWQYFTpFHA.2152@.TK2MSFTNGP14.phx.gbl...
> As Tom says in a message a few hours ago, thanks for the DDL. It made it
> easy to help you. Generally speaking it is usually suggested to do this
in
> the UI, not use SQL to manipulate the dat to fit the UI. On the other
hand,
> if you are talking small load it is fine to do it this way:
> select numberOfDays,
> sum(case when numberOfRentals = 1 then rentalCost else 0 end) as
> Individual,
> sum(case when numberOfRentals = 5 then rentalCost else 0 end) as
> [Bundle(5)],
> sum(case when numberOfRentals = 10 then rentalCost else 0 end) as
> [Bundle(10)],
> sum(case when numberOfRentals = 20 then rentalCost else 0 end) as
> [Bundle(20)]
> from rentals
> group by numberOfDays
That would work great, but is there a way to do this by separating it by the
grouping. In otherwords, I don't know that it will always be 5, 10 and 20.
It might be some other grouping so I would like to do it where I am not
doing an "= 1", "= 2" type of scenario.
My boss might change it 6 months from now and have a bundle of 15.
Thanks,
Tom
> --
> ----
--
> Louis Davidson - http://spaces.msn.com/members/drsql/
> SQL Server MVP
>
> "tshad" <tscheiderich@.ftsolutions.com> wrote in message
> news:e8xikzRpFHA.1444@.tk2msftngp13.phx.gbl...
(30,1,100)
(30,5,400)
(60,1,175)
(60,5,700)
(90,1,225)
(90,5,900)
the
(20)
NumberOfDays,
but
>|||The only way is to use dynamic sql. You would automate the select clause
from the values in the table. Personally if the change is very seldom I
would just make it something that you change whenever it changes in the
table as it will take you longer to make this change than it will to hard
code the values five or six times, including testing.
----
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"tshad" <tfs@.dslextreme.com> wrote in message
news:ehlDmvUpFHA.3316@.TK2MSFTNGP14.phx.gbl...
> "Louis Davidson" <dr_dontspamme_sql@.hotmail.com> wrote in message
> news:OBWQYFTpFHA.2152@.TK2MSFTNGP14.phx.gbl...
> in
> hand,
> That would work great, but is there a way to do this by separating it by
> the
> grouping. In otherwords, I don't know that it will always be 5, 10 and
> 20.
> It might be some other grouping so I would like to do it where I am not
> doing an "= 1", "= 2" type of scenario.
> My boss might change it 6 months from now and have a bundle of 15.
> Thanks,
> Tom
> --
> (30,1,100)
> (30,5,400)
> (60,1,175)
> (60,5,700)
> (90,1,225)
> (90,5,900)
> the
> (20)
> NumberOfDays,
> but
>|||"Louis Davidson" <dr_dontspamme_sql@.hotmail.com> wrote in message
news:uXsuKCcpFHA.2904@.TK2MSFTNGP12.phx.gbl...
> The only way is to use dynamic sql. You would automate the select clause
> from the values in the table. Personally if the change is very seldom I
> would just make it something that you change whenever it changes in the
> table as it will take you longer to make this change than it will to hard
> code the values five or six times, including testing.
The problem is that this is one we are using and there are other companies
that will use the system that may not use the Bundles we are using so it
would not be just one change.
How would you use Dynamic Sql to do this?
This will be read into a DataGrid, and it would be easy to make the columns
visible/invisible based on the number of columns that are returned.
Thanks,
Tom
> --
> ----
--
> Louis Davidson - http://spaces.msn.com/members/drsql/
> SQL Server MVP
>
> "tshad" <tfs@.dslextreme.com> wrote in message
> news:ehlDmvUpFHA.3316@.TK2MSFTNGP14.phx.gbl...
>|||I also tried to add in the Rental ID to select statement and can't make it
work with the column titles. I tried using the titles from the "as column",
but got an error in the Group clause
I tried to change your statement to:
select numberOfDays,
single = case when numberOfRentals = 1 then rentalCost else 0 end,
bundle5 = case when numberOfRentals = 5 then rentalCost else 0 end,
bundle10 = case when numberOfRentals = 10 then rentalCost else 0 end,
bundle20 = case when numberOfRentals = 20 then rentalCost else 0 end,
singleID = case when numberOfRentals = 1 then rentalID else 0 end,
bundle5ID = case when numberOfRentals = 5 then rentalID else 0 end,
bundle10ID = case when numberOfRentals = 10 then rentalID else 0 end,
bundle20ID = case when numberOfRentals = 20 then rentalID else 0 end
from rentals
group by
numberOfDays,single,bundle5,bundle10,bun
dle20,singleID,bundle5ID,bundle10ID,
bundle20ID
and got:
Server: Msg 207, Level 16, State 1, Line 1
Invalid column name 'singleID'.
Server: Msg 207, Level 16, State 1, Line 1
Invalid column name 'bundle5ID'.
etc
I assumed you used the "sum" so you wouldn't have to list it in the "group"
clause (of course, I could be wrong here), as there is only 1 Rental Cost
for each NumberOfDays/NumberOfRentals.
Can I not use the title I set up in the select statement in the Group
clause?
thanks,
Tom
"tshad" <tscheiderich@.ftsolutions.com> wrote in message
news:u7tHB7ypFHA.320@.TK2MSFTNGP09.phx.gbl...
> "Louis Davidson" <dr_dontspamme_sql@.hotmail.com> wrote in message
> news:uXsuKCcpFHA.2904@.TK2MSFTNGP12.phx.gbl...
> The problem is that this is one we are using and there are other companies
> that will use the system that may not use the Bundles we are using so it
> would not be just one change.
> How would you use Dynamic Sql to do this?
> This will be read into a DataGrid, and it would be easy to make the
> columns visible/invisible based on the number of columns that are
> returned.
> Thanks,
> Tom
>|||"tshad" <tscheiderich@.ftsolutions.com> wrote in message
news:O2ZAZK0pFHA.3732@.TK2MSFTNGP09.phx.gbl...
>I also tried to add in the Rental ID to select statement and can't make it
>work with the column titles. I tried using the titles from the "as
>column", but got an error in the Group clause
> I tried to change your statement to:
> select numberOfDays,
> single = case when numberOfRentals = 1 then rentalCost else 0 end,
> bundle5 = case when numberOfRentals = 5 then rentalCost else 0 end,
> bundle10 = case when numberOfRentals = 10 then rentalCost else 0 end,
> bundle20 = case when numberOfRentals = 20 then rentalCost else 0 end,
> singleID = case when numberOfRentals = 1 then rentalID else 0 end,
> bundle5ID = case when numberOfRentals = 5 then rentalID else 0 end,
> bundle10ID = case when numberOfRentals = 10 then rentalID else 0 end,
> bundle20ID = case when numberOfRentals = 20 then rentalID else 0 end
> from rentals
> group by
> numberOfDays,single,bundle5,bundle10,bun
dle20,singleID,bundle5ID,bundle10I
D,bundle20ID
> and got:
> Server: Msg 207, Level 16, State 1, Line 1
> Invalid column name 'singleID'.
> Server: Msg 207, Level 16, State 1, Line 1
> Invalid column name 'bundle5ID'.
> etc
> I assumed you used the "sum" so you wouldn't have to list it in the
> "group" clause (of course, I could be wrong here), as there is only 1
> Rental Cost for each NumberOfDays/NumberOfRentals.
I was able to get it to work using your set and the sum statement. Not sure
if this is the best way, but it does work.
select numberOfDays,
sum(case when numberOfRentals = 1 then rentalCost else 0 end) as
Individual,
sum(case when numberOfRentals = 5 then rentalCost else 0 end) as
[Bundle(5)],
sum(case when numberOfRentals = 10 then rentalCost else 0 end) as
[Bundle(10)],
sum(case when numberOfRentals = 20 then rentalCost else 0 end) as
[Bundle(20)],
sum(case when numberOfRentals = 1 then rentalID else 0 end) as
IndividualID,
sum(case when numberOfRentals = 5 then rentalID else 0 end) as
[Bundle(5)ID],
sum(case when numberOfRentals = 10 then rentalID else 0 end) as
[Bundle(10)ID],
sum(case when numberOfRentals = 20 then rentalID else 0 end) as
[Bundle(20)ID]
from rentals
group by numberOfDays
thanks,
Tom
> Can I not use the title I set up in the select statement in the Group
> clause?
> thanks,
> Tom
> "tshad" <tscheiderich@.ftsolutions.com> wrote in message
> news:u7tHB7ypFHA.320@.TK2MSFTNGP09.phx.gbl...
>|||You don't want it to be in the group, but it has to be part of an aggregate.
Hence the sum. As long as it doesn't hurt performance this is a fine way to
do it.
----
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"Arguments are to be avoided: they are always vulgar and often convincing."
(Oscar Wilde)
"tshad" <tscheiderich@.ftsolutions.com> wrote in message
news:OGRUGV0pFHA.1464@.TK2MSFTNGP14.phx.gbl...
> "tshad" <tscheiderich@.ftsolutions.com> wrote in message
> news:O2ZAZK0pFHA.3732@.TK2MSFTNGP09.phx.gbl...
> I was able to get it to work using your set and the sum statement. Not
> sure if this is the best way, but it does work.
> select numberOfDays,
> sum(case when numberOfRentals = 1 then rentalCost else 0 end) as
> Individual,
> sum(case when numberOfRentals = 5 then rentalCost else 0 end) as
> [Bundle(5)],
> sum(case when numberOfRentals = 10 then rentalCost else 0 end) as
> [Bundle(10)],
> sum(case when numberOfRentals = 20 then rentalCost else 0 end) as
> [Bundle(20)],
> sum(case when numberOfRentals = 1 then rentalID else 0 end) as
> IndividualID,
> sum(case when numberOfRentals = 5 then rentalID else 0 end) as
> [Bundle(5)ID],
> sum(case when numberOfRentals = 10 then rentalID else 0 end) as
> [Bundle(10)ID],
> sum(case when numberOfRentals = 20 then rentalID else 0 end) as
> [Bundle(20)ID]
> from rentals
> group by numberOfDays
> thanks,
> Tom
>|||Isn't always the case?
As soon as I have it set up (as you suggested), it is necessary to make it
completely flexible (could be bundles of 17, 22, 80, etc). You just can't
win.
Tom
"Louis Davidson" <dr_dontspamme_sql@.hotmail.com> wrote in message
news:uEm20w0pFHA.3064@.TK2MSFTNGP15.phx.gbl...
> You don't want it to be in the group, but it has to be part of an
> aggregate. Hence the sum. As long as it doesn't hurt performance this is
> a fine way to do it.
> --
> ----
--
> Louis Davidson - http://spaces.msn.com/members/drsql/
> SQL Server MVP
> "Arguments are to be avoided: they are always vulgar and often
> convincing." (Oscar Wilde)
> "tshad" <tscheiderich@.ftsolutions.com> wrote in message
> news:OGRUGV0pFHA.1464@.TK2MSFTNGP14.phx.gbl...
>

Grid Computing for Sql Server 2005?

Probably a bad way to start but wondering if Sql Server 2005 scales the way Grid computing does (ie several instances attached to same DB) by adding cheap hardware which is load balancing requests. Or is there only the option of adding more CPU's to the existing frame to scale the Sql Server 2005 DB?

We are migrtating to 2005 from 2000 and have several questions about maintaining a sql server 2000 failback DB that is kept in sync with the new 2005 DB after it goes production.

I was hoping to be able to detach a 2000 database and re-attach it to 2000 but seems not to work or at least backup and restore the 2005 databases and recover into 2000 but don't see that option. At last resort using something like DataMirror to maintain a synced version of DB in sql server 2000. Any suggestions or help here would be very appreciated.

We are planning side-by-side upgrade path currently running IA64 on unisys. This is a large 450gig OLTP Database.

Also we do replication and seems that Log reader really pounds the disk where logs are located. Suggestions on how to tune/reduce I/O on that disk? Have read plenty of papers and we are taking the 15 steps but wonder if 2005 does a better job of replication using the log files.

Thank You Very Much

sqlserver is builtin on "shared-nothing" technology. There is no way to get multiple instances of sqlserver to mount a same database for read_write. However, with sql2k5, you now have a way to allow multiple instances of sqlserver sharing a same database for readonly (i.e. scalable shared database).

http://support.microsoft.com/?kbid=910378|||

Unfortunately, you cannot use DB mirroring between SQL Server 2005 and SQL Server 2000. You cannot detach from SQL 2005 and reattach to SQL 2000. You also cannot backup from SQL 2005 and restore to SQL 2000. Basically, going from SQL 2000 to SQL 2005 is a one way trip.

Why do you want to keep a fallback SQL Server 2000 database? SQL Server 2005 has been out for nearly a year, and SP1 has been out for several months now. SQL Server 2005 is very solid now. You can run the Mcrosoft SQL Server Best Practices Analyzer on your existing SQL Server 2000 database to identify possible issues in upgrading to SQL Server 2005, and you can also run the Upgrade Advisor. You can and should do as much testing as possible to make sure that your application runs without issue on SQL Server 2005 before you upgrade in production. One common issue is inline SQL that uses non-ansi outer joins, which will fail on SQL Server 2005 in 90 compatibility mode.

I think a side by side upgrade (by running SQL 2005 as a named instance) on the same server is not the best idea. If you have the budget, you would be much better off to have a new server with a fresh copy of the OS to install SQL 2005 as the default instance. Then, if you can afford an outage, you can detach your SQL Server 2000 database, copy the files to another location on the SAN, and then attach in SQL 2005 on the new server.

If you cannot afford a long enough outage to copy the data files, you can simply detach from SQL Server 2000, then attach in SQL Server 2005. This is more risky, because you cannot go back if there is a problem. You would have to restore to SQL Server 2000 from a backup.

Basically, you either have to take a fairly long outage or take some risk when you upgrade. Spending money on a second new server can reduce the risk or reduce the length of the outage.