Showing posts with label net. Show all posts
Showing posts with label net. Show all posts

Thursday, March 22, 2012

Calculate weekend days between two dates.

How do I calculate the number of wends that are between two dates?
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!http://www.aspfaq.com/2519
http://www.aspfaq.com/
(Reverse address to reply.)
"skb" <nospamskberen@.msn.com> wrote in message
news:ezJye1qGFHA.3068@.tk2msftngp13.phx.gbl...
> How do I calculate the number of wends that are between two dates?
>
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!|||I dont think there is a direct function to do this.. but here is a way
around....(Please excause any syntex errors.. I am just writing off
the top of my head..)
-- ****************************************
****************
Declare @.startdate smalldatetime,
@.enddate smalldatetime,
@.tempdate datetime,
@.holiday smallint
set @.startdate = '01/01/2005' -- set to relevent start date
set @.enddate = '01/31/2005' -- set to relevent end date
set @.holiday = 0
Set @.tempdate = @.startdate
while @.tempdate <= @.enddate
begin
print convert(varchar, @.tempdate) + ' : ' + DateName (dw, @.tempdate )
if DateName (dw, @.tempdate ) = 'Saturday'
begin
print @.holiday
set @.holiday = @.holiday + 1
end
if DateName (dw, @.tempdate ) = 'sunday'
begin
print @.holiday
set @.holiday = @.holiday + 1
end
set @.tempdate = dateadd(d,1,@.tempdate)
end
select 'Total number of holidays between ' + convert (Varchar,
@.startdate) + ' to ' + convert (Varchar, @.enddate) + ' : ' + convert
(varchar, @.holiday)
-- ****************************************
****************|||If you only need wends remove the sunday check!!!!|||Build a calendar table with one column for the calendar data and other
columns to show whatever your business needs in the way of temporal
information. Do not try to calculate holidays in SQL -- Easter alone
requires too much math.
CREATE TABLE Calendar
(cal_date DATE NOT NULL PRIMARY KEY,
fiscal_year SMALLINT NOT NULL,
fiscal_month SMALLINT NOT NULL,
w_in_year SMALLINT NOT NULL, -- SQL server is not ISO standard
holiday SMALLINT NOT NULL
CHECK(holiday IN (0,1)),
day_in_year SMALLINT NOT NULL,
..);
A calendar table for US Secular holidays can be built from the data at
this website, so you will get the three-day wends:
http://www.smart.net/~mmontes/ushols.html|||Thanks for the help...For performance I think creating a table with
wend dates is the best.
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!

Sunday, March 11, 2012

Caching with Dynamic Security

I defined one role in my AS database with dynamic security for each dimension. I am accessing the AS database in an ASP.NET web application which runs under a domain user and uses Form Authentication. Therefore I always connect to the AS database under the same domain user even though security should be based on the user logged into the web application. When I run a MDX query, I pass along the web user's security info as part of the connectionstring and uses dynamic security to get the AllowedSet for each dimension. However, I notice my user defined function is ran only on the first time I run a query, meaning the dimension security is cached based on the domain user in the connection string and not the web user. Sorry if this sounds confusing but I can clarify a bit more if needed. My question boils down to: Is there a way to tell AS database to cache result base on the CustomData property of the connectionstring?

The answer is YES - AS is smart enough to recognize that different values of CustomData were used even though the real identity on the connection is the same. Since the main purpose of CustomData was for custom authentication - it is treated the same as different users. Same is true w.r.t. Roles and UserId properties.

HTH,

Mosha (http://www.mosha.com/msolap)

|||

Mosha,

As always, you are right and thanks for the help. I did a little more testing after my post and realized AS is caching the result base on the CustomData property. Thanks!

Thursday, March 8, 2012

Caching of inline queries

Hi,
I am trying to evaluate the benefits of writing stored procedures over
using inline SQL code using ADO.net and SqlServer. I am coming from an
oracle background, and am trying to understand under what
circumstances SqlServer will recompile my query, and when it will use
a pre-compiled version. The Oracle term for this behavior is
'bind-variable'. The only Oracle/bind-variable related information I
found here was
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=e0dtNgY%24CHA.2572%40TK2MSFTNGP11.phx.gbl
It seems to indicate that in order to avoid recompilation that I could
use stored procedures, format my queries using sp_executesql, or use
the prepared statement in my command object and reuse the object.
I am confused because by examining the syscacheobjects, it seems my
parameterized query is cached and reused automatically.
Here is what I am doing to test this. I have some code that looks like
this:
SqlConnection MyConnection = new SqlConnection(ConnectionString);
MyConnection.Open();
SqlCommand MyCommand = new SqlCommand("SELECT GStudentId, Lastname,
FirstName FROM student WHERE GStudentId=@.StudentId", MyConnection);
MyCommand.Parameters.Add("@.StudentId", _GStudentId);
SqlDataReader MyReader = MyCommand.ExecuteReader(CommandBehavior.CloseConnection);
I call this code on a simple web page, which lets me easily execute it
again and again.
I then do the following query inside Query Analyzer:
select usecounts, sql from syscacheobjects
where sql like '%SELECT GStudentId, Lastname, FirstName FROM student
WHERE GStudentId=@.StudentId%'
As I execute the page over and over the use count goes up.
Syscacheobjects actually returns two rows, one with a cached object
type of ?Executable Plan' (this is the one with the ?incrementing
usecounts'), and one with a type of ?Compiled Plan'. What are these
each used for?
Doesn't this mean that Sql Server is caching the query? I am
recreating the command object from scratch each time, yet it seems to
use the same "cached execution plan".
I am very happy with this behavior, yet it is in contradiction to the
other information I was able to find.
Can someone validate?
Thanks!
DaveSQL Server will do SIMPLE parameter substitution to reuse an ad-hoc plan.
That's probably what's happening in your example, but this will only happen
in trivial cases. You're better off with a proc us sp_executesql.
This paper is a good starting point for understanding SQL Server
behaivior...
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsql2k/html/sql_queryrecompilation.asp
--
Brian Moran
Principal Mentor
Solid Quality Learning
SQL Server MVP
http://www.solidqualitylearning.com
"HaukiDog" <HaukiDog@.hotmail.com> wrote in message
news:6d3bc6d9.0311241301.58817947@.posting.google.com...
> Hi,
> I am trying to evaluate the benefits of writing stored procedures over
> using inline SQL code using ADO.net and SqlServer. I am coming from an
> oracle background, and am trying to understand under what
> circumstances SqlServer will recompile my query, and when it will use
> a pre-compiled version. The Oracle term for this behavior is
> 'bind-variable'. The only Oracle/bind-variable related information I
> found here was
>
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=e0dtNgY%24CHA.2572%40TK2MSFTNGP11.phx.gbl
> It seems to indicate that in order to avoid recompilation that I could
> use stored procedures, format my queries using sp_executesql, or use
> the prepared statement in my command object and reuse the object.
> I am confused because by examining the syscacheobjects, it seems my
> parameterized query is cached and reused automatically.
> Here is what I am doing to test this. I have some code that looks like
> this:
> SqlConnection MyConnection = new SqlConnection(ConnectionString);
> MyConnection.Open();
> SqlCommand MyCommand = new SqlCommand("SELECT GStudentId, Lastname,
> FirstName FROM student WHERE GStudentId=@.StudentId", MyConnection);
> MyCommand.Parameters.Add("@.StudentId", _GStudentId);
> SqlDataReader MyReader => MyCommand.ExecuteReader(CommandBehavior.CloseConnection);
> I call this code on a simple web page, which lets me easily execute it
> again and again.
> I then do the following query inside Query Analyzer:
> select usecounts, sql from syscacheobjects
> where sql like '%SELECT GStudentId, Lastname, FirstName FROM student
> WHERE GStudentId=@.StudentId%'
> As I execute the page over and over the use count goes up.
> Syscacheobjects actually returns two rows, one with a cached object
> type of 'Executable Plan' (this is the one with the 'incrementing
> usecounts'), and one with a type of 'Compiled Plan'. What are these
> each used for?
> Doesn't this mean that Sql Server is caching the query? I am
> recreating the command object from scratch each time, yet it seems to
> use the same "cached execution plan".
> I am very happy with this behavior, yet it is in contradiction to the
> other information I was able to find.
> Can someone validate?
> Thanks!
> Dave

Wednesday, March 7, 2012

Cache Problem - URGENT HELP !

Dear All,
I have web application (ASP.NET) where I use SQL Server Std Server
engine as backened.
The issue that I have noticed whenever I ran "perfmon" the Total Pages
and Cache Pages alway showss 100 which is topmost.
My WEB application execute many SP that return data to client. In most
of SPs I create Temp Table and drop the same upon completion of SP.
Also I get an alert from SQL Performance monitor tool which is shown
below:
" Not enough physical memory has been left for NT; this will cause
excessive NT paging, resulting in poor performance."
My SQL Server RAM 1 GB. Have configured SQL Server to "to dynamically
confgiure SQL memory"
Do you know what could be the problem of hitting "Total Pages" and
"Cache Pages" 100.
Kindly help and advise..
Many thanks in advance
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!If you only have 1 GB of RAM on the server, and the memory is maxed out, I
would check the counters in Performance Monitor to see if it indicated a
need for more RAM in the box... Are you running IIS and SQL Server on the
same box? Try setting your SQL Server to use a fixed amount of RAM (maybe
800 MB depending on what else you have running on that box?)
"Ahmed Jewahar" <ahmed.jewahar@.dhl.com> wrote in message
news:%23q3Gl6tMFHA.3328@.TK2MSFTNGP14.phx.gbl...
> Dear All,
> I have web application (ASP.NET) where I use SQL Server Std Server
> engine as backened.
> The issue that I have noticed whenever I ran "perfmon" the Total Pages
> and Cache Pages alway showss 100 which is topmost.
> My WEB application execute many SP that return data to client. In most
> of SPs I create Temp Table and drop the same upon completion of SP.
> Also I get an alert from SQL Performance monitor tool which is shown
> below:
> " Not enough physical memory has been left for NT; this will cause
> excessive NT paging, resulting in poor performance."
> My SQL Server RAM 1 GB. Have configured SQL Server to "to dynamically
> confgiure SQL memory"
> Do you know what could be the problem of hitting "Total Pages" and
> "Cache Pages" 100.
> Kindly help and advise..
> Many thanks in advance
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!|||Michael,
Thanks for reply.
Yes, I have IIS and SQL on same box. I tried below statment to check
memory used which is return 753 MB used.
Also I checked following counters on "Performance" monitor this AM which
return as follows:
Object: SQL Server: Memory Manager:
--
Counter: Total Server Memory (KB) shows between 75-80
Object: Memory
--
Counter: Cache Bytes shows 100
Object: SQL Server: Cache Manager:
--
Counter: Cache Pages Shows between 50-55
Counter: Cache Object Counts 100
Object: ASP.NET Application
--
Counter: Cache Total hits shows 100
Due to all above, I suspect that my application might have affected it's
performance. I mean, in terms of speed.
How can I resolved this problem ?. Shall I increase the RAM ? What about
the Cache counters ? The pages in the cache, would it increase the
performance or decrease the performance ?
What about if I apply following DBCC commands ?. Will it help ?
DBCC FREEPROCCACHE
DBCC DROPCLEANBUFFERS
I would really appreciate your tips or advise to increase the
performance of the application.
Many thanks in advance...
Regards,
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!|||My first thoughts would be - if at all possible, get IIS on it's own box.
If not possible, I would set SQL Server to have a Fixed Memory size.
Offhand I would say that your memory might be a bottleneck - to find out for
sure, you might want to check other counters. Here's a page that lists some
other counters you might want to check to verify that it is a memory
problem:
[url]http://www.sql-server-performance.com/performance_monitor_counters_memory.asp.[/ur
l]
If you determine it is a memory problem, your best bet might be to add some
memory to the box...
"Ahmed Jewahar" <ahmed.jewahar@.dhl.com> wrote in message
news:OBd7ZE2MFHA.3328@.TK2MSFTNGP14.phx.gbl...
> Michael,
> Thanks for reply.
> Yes, I have IIS and SQL on same box. I tried below statment to check
> memory used which is return 753 MB used.
>
> Also I checked following counters on "Performance" monitor this AM which
> return as follows:
> Object: SQL Server: Memory Manager:
> --
> Counter: Total Server Memory (KB) shows between 75-80
> Object: Memory
> --
> Counter: Cache Bytes shows 100
> Object: SQL Server: Cache Manager:
> --
> Counter: Cache Pages Shows between 50-55
> Counter: Cache Object Counts 100
> Object: ASP.NET Application
> --
> Counter: Cache Total hits shows 100
> Due to all above, I suspect that my application might have affected it's
> performance. I mean, in terms of speed.
> How can I resolved this problem ?. Shall I increase the RAM ? What about
> the Cache counters ? The pages in the cache, would it increase the
> performance or decrease the performance ?
> What about if I apply following DBCC commands ?. Will it help ?
> DBCC FREEPROCCACHE
> DBCC DROPCLEANBUFFERS
> I would really appreciate your tips or advise to increase the
> performance of the application.
> Many thanks in advance...
> Regards,
>
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!

Cache ODBC dsn problem in Connection Manager

I have created a simple SSIS package using the Import / Export wizard. I have, in Connection Manager, created a DataReaderSrc connection using .Net Providers\ODBC Provider to connect to my exising DSN name of AMPFM which is an ODBC connection to a InterSystems Cache Database. It test successfully but fails when I run the package with the error at the bottom of this text. I have also tried the following connection string which also tests successfully but then fails when I run the package:

Dsn=AMPFM;server=10.11.1.34;uid=_system;port=1972;database=ALL;query timeout=1

SSIS package "Package1.dtsx" starting.

Information: 0x4004300A at Data Flow Task, DTS.Pipeline: Validation phase is beginning.

Error: 0xC0047062 at Data Flow Task, Source - Query [1]: System.Data.Odbc.OdbcException: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

at Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSConnectionManager90.AcquireConnection(Object pTransaction)

at Microsoft.SqlServer.Dts.Pipeline.DataReaderSourceAdapter.AcquireConnections(Object transaction)

at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostAcquireConnections(IDTSManagedComponentWrapper90 wrapper, Object transaction)

Error: 0xC0047017 at Data Flow Task, DTS.Pipeline: component "Source - Query" (1) failed validation and returned error code 0x80131937.

Can someone help me with this problem? I need to create several packages to pull data from this Cache database on a regular basis and find myself stuck at this step.

Thanks!

A few more details might help point me/others in the right direction. Specifically:

* Do I understand correctly that when you click "Test Connection" from inside the designer, it's succeeding?

* Can you try running the package in the debugger (i.e. Debug | Start Debugging), and report on whether the connection manager is able to connect there?

* Is it possible that the "Source - Query [1]" component on your Data Flow Task is configured to use a different connection manager than the one you're configuring? (Unlikely, but possible.)

* How are you executing the package (dtexec, dtexecui, designer, etc.) when it fails? Are you running as the same user as you're designing with? Also if you're running under Vista, are you running the package as an Administrator?

* Is your DSN a User or System DSN?

Thanks, -David

|||

Here is additional information David:

This SSIS 2005 package is using a 32-bit ODBC system dsn that worked successfully with SQL Server 2000 DTS packages.

I have a SQL Server 2005 x64 Enterprise database system on Windows 2003 x64 Enterprise.

The source query is using the DataReaderSrc connection manager which connects sucessfully when clicking on "Test Connection"

The package is only being tested in BIDS using Debug with my userid which is also the userid that created the package

Thanks!

|||

Maybe you are running 32-bit ODBC driver in 64-bit mode. Is your driver 32-bit only?

To check this quickly: right-click on your IS project in VS, choose Properties, select the Debugging node and switch the Run64BitRuntime flag to false.

HTH.

|||

That is exactly what was happening, the driver is only 32-bit! I had heard of the Run64BitRuntime flag but could not find it before receiving your instructions above. The job is running correctly now. Thanks so much Bob!

Cache ODBC dsn problem in Connection Manager

I have created a simple SSIS package using the Import / Export wizard. I have, in Connection Manager, created a DataReaderSrc connection using .Net Providers\ODBC Provider to connect to my exising DSN name of AMPFM which is an ODBC connection to a InterSystems Cache Database. It test successfully but fails when I run the package with the error at the bottom of this text. I have also tried the following connection string which also tests successfully but then fails when I run the package:

Dsn=AMPFM;server=10.11.1.34;uid=_system;port=1972;database=ALL;query timeout=1

SSIS package "Package1.dtsx" starting.

Information: 0x4004300A at Data Flow Task, DTS.Pipeline: Validation phase is beginning.

Error: 0xC0047062 at Data Flow Task, Source - Query [1]: System.Data.Odbc.OdbcException: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

at Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSConnectionManager90.AcquireConnection(Object pTransaction)

at Microsoft.SqlServer.Dts.Pipeline.DataReaderSourceAdapter.AcquireConnections(Object transaction)

at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostAcquireConnections(IDTSManagedComponentWrapper90 wrapper, Object transaction)

Error: 0xC0047017 at Data Flow Task, DTS.Pipeline: component "Source - Query" (1) failed validation and returned error code 0x80131937.

Can someone help me with this problem? I need to create several packages to pull data from this Cache database on a regular basis and find myself stuck at this step.

Thanks!

A few more details might help point me/others in the right direction. Specifically:

* Do I understand correctly that when you click "Test Connection" from inside the designer, it's succeeding?

* Can you try running the package in the debugger (i.e. Debug | Start Debugging), and report on whether the connection manager is able to connect there?

* Is it possible that the "Source - Query [1]" component on your Data Flow Task is configured to use a different connection manager than the one you're configuring? (Unlikely, but possible.)

* How are you executing the package (dtexec, dtexecui, designer, etc.) when it fails? Are you running as the same user as you're designing with? Also if you're running under Vista, are you running the package as an Administrator?

* Is your DSN a User or System DSN?

Thanks, -David

|||

Here is additional information David:

This SSIS 2005 package is using a 32-bit ODBC system dsn that worked successfully with SQL Server 2000 DTS packages.

I have a SQL Server 2005 x64 Enterprise database system on Windows 2003 x64 Enterprise.

The source query is using the DataReaderSrc connection manager which connects sucessfully when clicking on "Test Connection"

The package is only being tested in BIDS using Debug with my userid which is also the userid that created the package

Thanks!

|||

Maybe you are running 32-bit ODBC driver in 64-bit mode. Is your driver 32-bit only?

To check this quickly: right-click on your IS project in VS, choose Properties, select the Debugging node and switch the Run64BitRuntime flag to false.

HTH.

|||

That is exactly what was happening, the driver is only 32-bit! I had heard of the Run64BitRuntime flag but could not find it before receiving your instructions above. The job is running correctly now. Thanks so much Bob!

Cache Dependency Problem

Hello.

I am having problems with SQL Cache dependency. I am using SQL 2005, ASP .net 2.0.

Every time i try to load data from cache, this is null. It acts like someone is constantly changing everything in the db.

Because of this my website makes hundreds of connections to the db instead of 5. This is a major issue that i cannot figure it out. PLEASE ADVISE.

On my local machine everything seems to work just fine. On the testing server the cache is always null.

Is cache dependency related

- to the platform used?

- to the number of IIS servers connected to the DB?

- to the sql user used?

Also a strange thing happens. When i change something in web.config the cache is working for about 1 min and after that it stops.

Here is the code i wrote:

public ManufacturerList GetAllManufacturers()
{
if (HttpContext.Current.Cache[ConstantsManager.Instance.GetDefaultAsString("CACHE_MANUFACTURERS")] != null)
return HttpContext.Current.Cache[ConstantsManager.Instance.GetDefaultAsString("CACHE_MANUFACTURERS")] as ManufacturerList;

SqlCacheDependency dep = new SqlCacheDependency(ConstantsManager.Instance.GetDefaultAsString("DB_NAME"), ConstantsManager.Instance.GetDefaultAsString("TABLE_MANUFACTURERS"));

_manufacturerList = new ManufacturerList();

DataReader reader = SqlHelper.ExecuteDataReader(WebContext.ConnectionString, CommandType.StoredProcedure, "dvx_web_MANUFACTURER_LoadAll", null);

while (reader.Read())
{
int manufacturerID = reader.GetInt("ID");

Manufacturer findManufacturer = _manufacturerList.FindByID(manufacturerID);

if (findManufacturer == null)
{
findManufacturer = new Manufacturer();
findManufacturer.LoadFromDataReader(reader);
_manufacturerList.Add(findManufacturer);
}
}

reader.Close();

HttpContext.Current.Cache.Insert(ConstantsManager.Instance.GetDefaultAsString("CACHE_MANUFACTURERS"), _manufacturerList, dep);

return _manufacturerList;
}

Thanks a lot.

Hi,

Look at this article describing some ways of using SQL Dependency Cache.

http://www.ondotnet.com/pub/a/dotnet/2005/01/17/sqlcachedependency.html

Saturday, February 25, 2012

C++ .net data binding

I have a datagrid control bound to a dataview of a table in a dataset.
I am using a tablestyle to control which of the table columns are
displayed in the datagrid. When any cell in a row is selected I want to
select and highlight the entire row.
By catching the mousedown event and using HitTest I can work out what
row was clicked on the control and set the selected row but I can
highlight the row.
Can anyone tell me where I am going wrong ?"Jez" <jezario@.hotmail.co.uk> wrote in message
news:1129131568.948426.123380@.g14g2000cwa.googlegroups.com...
>I have a datagrid control bound to a dataview of a table in a dataset.
> I am using a tablestyle to control which of the table columns are
> displayed in the datagrid. When any cell in a row is selected I want to
> select and highlight the entire row.
> By catching the mousedown event and using HitTest I can work out what
> row was clicked on the control and set the selected row but I can
> highlight the row.

> Can anyone tell me where I am going wrong ?
Posting in the wrong newsgroup. :-)

Friday, February 24, 2012

C#/SQL noob question

Using C# and ASP.NET, I need to connect to an SQL Server running Reporting Services, grab a report, supply a couple of parameters and an output format, and render a stream that I can write to a browser. Can anybody point me to an example or tutorial explaining how to do that?

thanks!

You probably want to start here:

http://msdn.microsoft.com/sql/bi/reporting/default.aspx?pull=/library/en-us/dnsql90/html/integratrsapp.asp

C#, VB.NET & RS

Is it true thar RServices uses VB.NET syntax for functions (converting types,iif,CDate,..) apart from choosing C# IB project?
AlešYes, check
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/RSCREATE/htm/rcr_creating_expressions_v1_3983.asp
for details.
--
Ravi Mumulla (Microsoft)
SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
<AG>; "NLB d.d." <AGNLBdd@.discussions.microsoft.com> wrote in message
news:CC0399FA-15B7-417F-B029-2243CC80B288@.microsoft.com...
> Is it true thar RServices uses VB.NET syntax for functions (converting
types,iif,CDate,..) apart from choosing C# IB project?
> Aleš

C# with ADO 2.8: Receiving "Current Recordset does not support updating"

Hi All,

I was using VB6 to access a MS SQL Server database. The code worked and works fine. I then decided to migrate the code to C#.Net 2005 using ADO 2.8 (not ADO.Net). Doing that yields with the same exact code the error message, "Current Recordset does not support updating".

I did a whole bunch of Google searches and didn't see anything useful. Mainly the advice from Microsoft and others is to make sure the mode on the connection string is set to "ReadWrite", as the default is "Read Only" and to make sure to set the lock type to either optimistic or pessimistic. Still others said that the code should set the CursorLocation property of the recordset.

I can safely say that I have been setting the mode to "Read/Write" since the start and have played around with the lock type, cursor location, and open method. Nothing works on C#, BUT VB6 is so totally happy with everything.

The provider works fine, as VB6 works fine, and the lock type is also fine, so therefore the built in suggestions do not apply.

My code is:

// Connection string template. Filled in properly in real code.
strConnect = "Server={0};Database={1};"

// Set the connection properties.
this.SQLConnection.ConnectionString = strConnect;
this.SQLConnection.Provider = "SQLOLEDB";
this.SQLConnection.Mode = adModeReadWrite;

// Open the connection.
this.SQLConnection.Open(strConnect, strUserName, strPassword, -1);

=================

// Create the ADO objects needed.
dbRSAdd = new Recordset();

// Open the recordset.
dbRSAdd.Open(strTable, dbCatalog.ActiveConnection, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic, (int)CommandTypeEnum.adCmdTable);

// Cycle through each record to add.
dbRS.MoveFirst();
for (lRecord = 0; lRecord < dbRS.RecordCount; lRecord++)
{
// Add a new record.
dbRS.AddNew(System.Reflection.Missing.Value, System.Reflection.Missing.Value);

...
}

// NOTE: The code crashes with the call to 'AddNew'.

Any advice?Hi All,

(Head between my legs.) I can't tell you how long I looked at the code only to look at the code on this post and immediately see the problem. I had two record sets. The first record set (dbRS) is read only. I made the stupid mistake of not putting dbRSAdd with the AddNew. VB6 uses a 'With' statement, whereas C# does not support a 'With' statement. My problem was that I wasn't careful in copying and pasting, when filling in the prefix before the '.'.

Oops!

C# SQL ID field Datagrid and DataSource

OK I am a newbie when it comes to lots of .Net so if you answer go slowwww. I have an auto incrementing ID field in a SQL database.

This is all displayed to the user in a datagrid control. I add two or three new rows and AcceptChanges.

At this point I my ID field displayed on the grid bound tot he SQL ID field is out of Sync. What the#@.^%#$&*

In fact it looks like the data grid placed in its own numbers by doing some sort of Maxvalue on the column.

HELP!

Bob

Chicago_Bob:

In fact it looks like the data grid placed in its own numbers by doing some sort of Maxvalue on the column.

Can you explain more about what's the exact problem you're facing? How does the indentity column look like now? Do you mean the new rows got wrong IDs (not the maxID+1/+2)?

|||

I did some digging last night to find I am not alone in this problem this is a thing that might be addressed by

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconretrievingidentityorautonumbervalues.asp

I am not sure yet but to tell you the truth this bites. The ID column beucase the dataset is disconected does not stay in sync with the

ID column. SQL can be on number 999 and the ID will be MAX ID of the record set + 1. YIKES!!! And the error is only know when you

try to update the record set. It will reply with a Concurency error. DOH! It took a while to relate the 2 together. Who would have thought..

Anyway the dataset the DataGrid and therefore the results of the DataGrid are not correct when you accept changes and you have a SQL table with an autoincrement field. NOT GOOD.. There is nothing anywhere that spells this out when you read about the DataSet or DatGrid.

In fact web searching turns up little if anything at all. Guess thats what I guess for using those pretty tools in .NET eh?

Bob

|||

Rant mode.

I thought this was a 3 maybe 4 hour job. MultiLine copy and Paste addition to the DataGrid control. I already had the code to do a one line copy and paste. So what a little loop code and I was out of there.. That would be normal. But what in using RAD tools is normal? I did finally get my multirow copy and paste to work but it took quite a bit of playing "twist the code" and it was not pleasant. Here is a few of the issues that I hit like a brick wall.

I use a SQL autoincrement ID field so multiple users can be making changes etc. WELL bad idea with the DataGrid.. First the ID sync is not in sync with SQL server. You have to cusomize your autogenerated code to do insert to work with a Stored Proc so you can get a value back which is the magical ID. How intuitive that was. I saw no mention of this anywhere in the Grid docs. The error is special as well "Concerency error " (which makes total sense to eveyrone here I am sure but not to me) when I did not have my ID's displayed. So after 1 day of fishing on the Net I get some info about how to do this with a data set. Its the link above. It does work butWARNING if you even look at your XSD and check some properties and save the OLD code I had for insert whacks the new. So after retyping again I am afraid to go back and even breath on that stuff..

Now onto the multiple other hurdles. If you have a bound Grid control youcan not simply add a row. WHY? Cause its bound the compiler tells me, But thats why I bound it! I bound it so I can use the Grid to manipulate the dataset. I was stumped for an aswer until I saw that you can get the last row of the Grid by usingdataGridView1.NewRowIndex; COOL I fill in the data and do the Accept and update and .... Nothing. The data is added to the Grid but not to SQL. BUMMER. After playing around for several hours with this idea and that I got a new idea.I need to add a row so I figure you add a record to the dataset. Yeah that should do it. Great three lines of code to add the row. I change my paste function to place data into each data field in the new data row and do an update and accept. I query SQL Server using Enterpirse manager and see the data is there but the grid? It shows nothing. Empty...?

Isnt the Grid suppossed to update with the new data when I update the dataset and accept the data with adapter. Guess NOT.. I thought they were connected. Oh well I go back to the old code and add data to the grid and add a new row this caused me to get 2 rows for every one that I added. Yeah that was FUN but I figured out why that was happening. The index to the Grids row would update as soon as you add row a row to the dataset. This would start my new row below my old row and I would 2 records in SQL and one would be blank etc. Bad Stuff. Here is the original snipit.

instEditsDataSet1.EQ_IntranetReportData.Rows.Add(myRow);

row = dataGridView1.NewRowIndex;

// add a row to the data set.

dataGridView1.CurrentCell = dataGridView1[0, row];

------ BUT if you switchit around -----

// add a row to the data set.

row = dataGridView1.NewRowIndex;

instEditsDataSet1.EQ_IntranetReportData.Rows.Add(myRow);

dataGridView1.CurrentCell = dataGridView1[0, row];

all is good. This will get you a place to start adding data from the copy.

GEE I thought these were supposed to be connected? But they are a pain So I add new data to the DataRow and simultaneously add data to the Grids Cells on that row. Do my update and accept and it works.. EXCEPT when you use a filter. Then it all goes bad.

So you must take save all filters and sorts then put em back later.

All in all 3 normal days.. Now that was what I call a RAD tool.Hmm

Rant Mode off.

Sunday, February 12, 2012

Business Intelligence Projects - Visual Studio Net 2003

Hi,
i must create a new report for Reporting Services. In Visual Studio Net 2003 (new project) i don't find the folder "business intelligence projects".
Can you help me?

thanks

Hi,

You have to install Reporting Services Client from Report Designer component on your own PC.

Anders

Business Intelligence Project type missing

Using VS.Net 2003, I don't have the Business Intelligence Project type. I
have installed Reporting Services today and would like to start creating
some projects with it.
When installing reporting services, I didn't install the server software on
the same machine as VS.Net. I don't need to do that do I?
Thanks in advance,
MarkMBRUND wrote:
> Using VS.Net 2003, I don't have the Business Intelligence Project type. I
> have installed Reporting Services today and would like to start creating
> some projects with it.
> When installing reporting services, I didn't install the server software on
> the same machine as VS.Net. I don't need to do that do I?
> Thanks in advance,
> Mark
>
Yup. You need to install the client tools on your development box.
Matt|||The server does not need the client software and the client software does
not need the server software. They can both be installed but they do not
need to be. Wherever you install the client software you need VS installed.
Bruce L-C
"MBRUND" <mark.brundieck@.midwestwirelessREMOVE_CAPS_AND_INVALID.com.invalid>
wrote in message news:OfobUD6YEHA.3892@.TK2MSFTNGP09.phx.gbl...
> Using VS.Net 2003, I don't have the Business Intelligence Project type. I
> have installed Reporting Services today and would like to start creating
> some projects with it.
> When installing reporting services, I didn't install the server software
on
> the same machine as VS.Net. I don't need to do that do I?
> Thanks in advance,
> Mark
>|||The server is already installed OK and others are able to program against it
using Business Intelligence Projects from VS.Net, but I can't though I have
installed the client the same way the others have.
I'm not sure what else is different about the VS.Net 2003 suite we are using
the the Reporting Services client software that is installed on the
machines. Any ideas what to look for? However, they are using Windows XP as
OS and I am using Windows 2000 Server.
Mark
"Bruce Loehle-Conger" <bruce_lcNOSPAM@.hotmail.com> wrote in message
news:O8v4nk6YEHA.996@.TK2MSFTNGP12.phx.gbl...
> The server does not need the client software and the client software does
> not need the server software. They can both be installed but they do not
> need to be. Wherever you install the client software you need VS
installed.
> Bruce L-C
> "MBRUND"
<mark.brundieck@.midwestwirelessREMOVE_CAPS_AND_INVALID.com.invalid>
> wrote in message news:OfobUD6YEHA.3892@.TK2MSFTNGP09.phx.gbl...
> > Using VS.Net 2003, I don't have the Business Intelligence Project type.
I
> > have installed Reporting Services today and would like to start creating
> > some projects with it.
> >
> > When installing reporting services, I didn't install the server software
> on
> > the same machine as VS.Net. I don't need to do that do I?
> >
> > Thanks in advance,
> > Mark
> >
> >
>|||Found it!
My bad. I have both VS.Net 2002 and VS.Net 2003 on this machine and didn't
expect it. I was looking for the project type using 2002, but I found it now
under 2003. Surprise! Now to get rid of 2002 ...
Thanks for your time.
"MBRUND" <mark.brundieck@.midwestwirelessREMOVE_CAPS_AND_INVALID.com.invalid>
wrote in message news:%23Dk4s7DZEHA.3944@.tk2msftngp13.phx.gbl...
> The server is already installed OK and others are able to program against
it
> using Business Intelligence Projects from VS.Net, but I can't though I
have
> installed the client the same way the others have.
> I'm not sure what else is different about the VS.Net 2003 suite we are
using
> the the Reporting Services client software that is installed on the
> machines. Any ideas what to look for? However, they are using Windows XP
as
> OS and I am using Windows 2000 Server.
> Mark
> "Bruce Loehle-Conger" <bruce_lcNOSPAM@.hotmail.com> wrote in message
> news:O8v4nk6YEHA.996@.TK2MSFTNGP12.phx.gbl...
> > The server does not need the client software and the client software
does
> > not need the server software. They can both be installed but they do not
> > need to be. Wherever you install the client software you need VS
> installed.
> >
> > Bruce L-C
> >
> > "MBRUND"
> <mark.brundieck@.midwestwirelessREMOVE_CAPS_AND_INVALID.com.invalid>
> > wrote in message news:OfobUD6YEHA.3892@.TK2MSFTNGP09.phx.gbl...
> > > Using VS.Net 2003, I don't have the Business Intelligence Project
type.
> I
> > > have installed Reporting Services today and would like to start
creating
> > > some projects with it.
> > >
> > > When installing reporting services, I didn't install the server
software
> > on
> > > the same machine as VS.Net. I don't need to do that do I?
> > >
> > > Thanks in advance,
> > > Mark
> > >
> > >
> >
> >
>

Business Intel. Dev. Studio loads VS.Net 2005

Hi,
I installed the Business Intelligence Development Studio but when I run it
it is just running my VS.Net 2005. Is this what it is supposed to do? I
want to run some imports/exports and it looked like I needed that installed.
There is no option in SQL Manager Studio to do Imports & Exports. At least
not in the Express CTP version. Does anyone know the EXE name of the file
that is supposed to run when launching the BIDS? The old Enterprise Manager
made importing and exporting a breeze and I'd really like to find where to
do that in SQL Server 2005. Thanks for any help!
Yes, BIDS is just a cut down VS2005 with limited projects avaulable. If you
have the full version of VS2005 installed it will just launch that and you
should see the BI project types in there. BIDS does not have any
import/export functionality, that's in Management Studio (full version not
Express version). Since it relies on SSIS which does not come with Express
then it makes sense it's no there. I'm not sure if this will be added at a
later stage to improve the usefulness of SSMS Express.
HTH,
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
"HTML" <test@.test.123> wrote in message
news:uH3UG9aKGHA.360@.TK2MSFTNGP12.phx.gbl...
> Hi,
> I installed the Business Intelligence Development Studio but when I run it
> it is just running my VS.Net 2005. Is this what it is supposed to do? I
> want to run some imports/exports and it looked like I needed that
> installed. There is no option in SQL Manager Studio to do Imports &
> Exports. At least not in the Express CTP version. Does anyone know the
> EXE name of the file that is supposed to run when launching the BIDS? The
> old Enterprise Manager made importing and exporting a breeze and I'd
> really like to find where to do that in SQL Server 2005. Thanks for any
> help!
>

Friday, February 10, 2012

BulkCopy problem

Hello,

I am using bcp in a stored procedure. I am calling the stored procedure with VB.NET 2.0. The stored procedure does work, but not every time. I can run the stored procedure from Server Manager Express, and it does run, but not every time.

Here is my bcp command. Is this correct?

set @.cmd = 'bcp '+@.dbname+'.dbo.'+@.tablename+' '+@.direction+' '+@.filepath+' -T -c -S .\SQLEXPRESS'

exec master..xp_cmdshell @.cmd

Thanks for any ideas on how to debug this.

Tom

It looks to be a problem of needing double quotes. (Dummy values supplied.)


Code Snippet


DECLARE
@.cmd nvarchar(250),
@.dbName varchar(25),
@.TableName varchar(25),
@.Direction varchar(3),
@.FilePath varchar(150)


SELECT
@.dbName = 'MyDataBase',
@.TableName = 'MyTable',
@.Direction = 'IN',
@.FilePath = 'c:\temp\input.csv'


SET @.cmd = 'bcp "' + @.dbname + '.dbo.' + @.tablename + '" ' +
@.direction + ' "' + @.filepath + '" -T -c -S .\SQLEXPRESS'


PRINT @.cmd


bcp "MyDataBase.dbo.MyTable" IN "c:\temp\input.csv" -T -c -S .\SQLEXPRESS

|||

Hi Arnie,

Thanks for taking time to reply to this issue.

Adding the quotes eliminated the problem where it was reporting an error on the filepath that contained spaces.

Now it is reporting this error:

Error = [Microsoft][SQL Native Client]Unable to open BCP host data-file

I have done some searching for the answer to this error, and I cannot find a solution. :-(

Thanks

MisterT

|||

I changed the permissions on the directory to allow Users "read" permission and it is now working.

Thank You,

Tom