Showing posts with label point. Show all posts
Showing posts with label point. Show all posts

Wednesday, March 21, 2012

Detecting (local) sql-server

Can someone please point me to some code (preferably C#, but C++ or C or VB
will work) that will detect if the (local) instance of SQL Server is
running on a machine or not? Many thanks!

-- Rob"Rob Gibson" <xnews@.rgibREMOVEson.net> wrote in message
news:Xns95FADFA7C4F67defffft1078@.216.196.97.142...
> Can someone please point me to some code (preferably C#, but C++ or C or
> VB
> will work) that will detect if the (local) instance of SQL Server is
> running on a machine or not? Many thanks!
> -- Rob

MSSQL is just another service, so you should look for code which shows how
to retrieve service states from C# - it looks as if there's a sample with
Visual Studio:

http://msdn.microsoft.com/library/d...scontroller.asp

If you have multiple instances, then see questions 12 and 13 here for how to
find the instance names:

http://support.microsoft.com/defaul...6&Product=sql2k

Simon|||"Simon Hayes" <sql@.hayes.ch> wrote in news:420dc8db$1_1@.news.bluewin.ch:

> MSSQL is just another service, so you should look for code which shows
> how to retrieve service states from C# - it looks as if there's a
> sample with Visual Studio:
> http://msdn.microsoft.com/library/d...ry/en-us/cssamp
> le/html/vcsamprocesscontroller.asp
> If you have multiple instances, then see questions 12 and 13 here for
> how to find the instance names:
> http://support.microsoft.com/defaul...257716&Product=
> sql2k
> Simon

Thank you, Simon! That's *EXACTLY* what I was looking for!

-- Rob

Detect (local) SQL Server

Can someone please point me to some code (preferably C#, but C++ or C or VB
will work) that will detect if the (local) instance of SQL Server is
running on a machine or not? Many thanks!
-- RobHi Rob
Try using the the ServiceController class to check to see if the MSSQLServer
service is running (ServiceControllerStatus.Running).
Cheers
J.
"Rob Gibson" <xnews@.rgibREMOVEson.net> wrote in message
news:Xns95FAE91589AFBdefffft1078@.216.196.97.142...
> Can someone please point me to some code (preferably C#, but C++ or C or
VB
> will work) that will detect if the (local) instance of SQL Server is
> running on a machine or not? Many thanks!
> -- Rob

Saturday, February 25, 2012

designing history tables

Could some one please point me to a good resource on how to design history
tables in a dataware house situation'
For example, in the case of products table, if product description got
changed over time after the product was purchased. The old invoice still
shows the old description but the table reflects the new one.
How could some one keep track of both descriptions?
What would be a good design/architecture'
TIA...Well, the invoices table should contain a relatively permanent piece of
data, such as a ProductID of some kind, not a much more flexible piece of
information like a description.
That said, it may still be useful to store the history of a product.
Probably the simplest in this very specific case would be:
CREATE TABLE dbo.ProductDescriptionHistory
(
ProductID INT NOT NULL
FOREIGN KEY REFERENCES dbo.Products(ProductID),
Description VARCHAR(255),
EffectiveDate SMALLDATETIME
)
This will allow you to reconstruct invoices from the past, with the correct
"at the time" description, without bloating the invoices table with a big
VARCHAR that will usually be redundant.
You will probably come across the same dilemma with price... do you store
price data for products where the price may or may not change, or do you
just reference the productID?
Your exact solution will at least partially depend on some of the
information you haven't provided, such as exactly why you need the historic
descriptions, what you're going to do with them, and how often they actually
change.
"sqlster" <nospam@.nospam.com> wrote in message
news:3F41C612-B1AB-441F-AED7-26F4C7ABEA09@.microsoft.com...
> Could some one please point me to a good resource on how to design history
> tables in a dataware house situation'
> For example, in the case of products table, if product description got
> changed over time after the product was purchased. The old invoice still
> shows the old description but the table reflects the new one.
> How could some one keep track of both descriptions?
> What would be a good design/architecture'
> TIA...|||<Aaron>
Your exact solution will at least partially depend on some of the
information you haven't provided, such as exactly why you need the historic
descriptions, what you're going to do with them, and how often they actually
change.
</Aaron>
I need the historic descriptions for the reporting purposes only. Some of
the values could change 10 - 15 times a month.
Thanks
"Aaron Bertrand [SQL Server MVP]" wrote:

> Well, the invoices table should contain a relatively permanent piece of
> data, such as a ProductID of some kind, not a much more flexible piece of
> information like a description.
> That said, it may still be useful to store the history of a product.
> Probably the simplest in this very specific case would be:
> CREATE TABLE dbo.ProductDescriptionHistory
> (
> ProductID INT NOT NULL
> FOREIGN KEY REFERENCES dbo.Products(ProductID),
> Description VARCHAR(255),
> EffectiveDate SMALLDATETIME
> )
> This will allow you to reconstruct invoices from the past, with the correc
t
> "at the time" description, without bloating the invoices table with a big
> VARCHAR that will usually be redundant.
> You will probably come across the same dilemma with price... do you store
> price data for products where the price may or may not change, or do you
> just reference the productID?
> Your exact solution will at least partially depend on some of the
> information you haven't provided, such as exactly why you need the histori
c
> descriptions, what you're going to do with them, and how often they actual
ly
> change.
>
> "sqlster" <nospam@.nospam.com> wrote in message
> news:3F41C612-B1AB-441F-AED7-26F4C7ABEA09@.microsoft.com...
>
>|||Keep who changed the rows and when in separate columns in the archive table.
You might also want to keep a record of whether the row in the main table wa
s
updated or deleted.
E.g.:
Main table:
Col1 : Col2 : ... : ColN
Archive table:
Col1 : Col2 : ... : ColN : ChangedDateTime : ChangedBy : ChangeType
Of course changes are propagated to the archive table via triggers on the
main table (for update and for delete).
For a more elaborate solution, please at least provide DDL.
ML
http://milambda.blogspot.com/|||ML,
I am just looking for some books/websites/articles that address good history
table design. The example that I brought up is just a hypothetical example s
o
I don't have any DDL.
TIA..
"ML" wrote:

> Keep who changed the rows and when in separate columns in the archive tabl
e.
> You might also want to keep a record of whether the row in the main table
was
> updated or deleted.
> E.g.:
> Main table:
> Col1 : Col2 : ... : ColN
> Archive table:
> Col1 : Col2 : ... : ColN : ChangedDateTime : ChangedBy : ChangeType
> Of course changes are propagated to the archive table via triggers on the
> main table (for update and for delete).
> For a more elaborate solution, please at least provide DDL.
>
> ML
> --
> http://milambda.blogspot.com/

Friday, February 24, 2012

design question about webservices

Hi,

I need to expose data in a SQL server 2005 database as a webservices. I have 2 options to choose. I can create an End point in sql or build a webservices in .NET.

So what are de advantages and disadvantages of those 2 approaches ?

Of course they want the webservices secure. I know that authentication is not a problem since we use windows integrated security for the intranet. But what will happen if we move to an extranet or the internet ?

But how do you enable authorization ? and Context security ? Is context security better done in .NET then in SQL ?

Thanks in advance.

Deciding which approach is better for your scenario will also depend on a couple key questions:

If the expected workload requires you to have some web farm like scalability, then you will need to go with ASP.NET If you need the ability to customize the WSDL generation and/or web method result structure then you need to go with ASP.NET|||

It is very clear.

Thank you very much.

CE

Tuesday, February 14, 2012

deserializing a collection which implements collectionbase

I had a post very similar to this a week or so ago and I received a couple good solutions ... unfortunately, I forgot to mention 1 point that apparently makes a big enough difference so that the solution given won't work. Here's what I originally posted
(and below that is more info):
I'm writing a class in C# ...
I have a collection calls Reports made up of Report objects. I'm trying to deserialize an XML file that looks like :
<Reports>
<Report>
<Title>some title</Title>
<Notes> some notes </Notes>
</Report>
<Report>
blah blah blah
</Report>
</Reports>
I want to be able to deserialize the file in the Reports collection constructor and build the Report objects on the fly. The only examples I've been able to find read the entire XML file outside of the class (which works fine in my test console app), but
I want to be able to be able to dynamically build everything inside the collection class. Do I need to parse through the XML file and got to each <Report> tag and deserialize one Report at a time (and use "this.Add(newReport)")? How can parse the file
like that and pass just that info into the deserialize method? I haven't used XPath, so if I need that, an example would really help.
NOW..........................
what I failed to mention was that my Reports collection implements CollectionBase and now I recieve the following error: "XML attributes may not be specified for the type TestCore.Reports"
I remove the CollectionBase implementation and it works. I've found several websites saying that I can deserialize a class implementing CollectionBase, but I haven't found any examples or help as to what I'm doing wrong. Here's what I have for the colle
ction class using the solution I received in my earlier post (if need be I can post more of my code):
[System.Xml.Serialization.XmlRoot("Reports", Namespace="", IsNullable=false)]
[System.Xml.Serialization.XmlType("Reports", Namespace="")]
public class Reports : CollectionBase
{
[System.Xml.Serialization.XmlElementAttribute "Report",Form=System.Xml.Schema.XmlSchemaForm.Unqu alified)]
public Report[] Items1;
public Reports() {}
public Reports(string path)
{
Reports temp= Reports.CreateFromString(path);
Items1= temp.Items1; // shallow copy of array. Would need to do this for each field in the RC type
// "temp" now goes out of scope but the Items array gets referenced by "this"
}
public static Reports CreateFromString(string xml1)
{
// could parameterize this with a filename, a stream, a string,whatever
XmlSerializer s1 = new XmlSerializer(typeof(Reports));
// slurp it in: deserialize the original XML into a value
System.IO.StringReader sr= new System.IO.StringReader(xml1);
Reports rc= (Reports) s1.Deserialize(new System.Xml.XmlTextReader(sr));
return rc;
}
public int Add(Report report)
{
return List.Add(report);
}
public Report this[int index]
{
get
{
return((Report)List[index]);
}
set
{
List[index] = value;
}
}
}
You need to remove the attributes from the class that derives from
CollectionBase.
The side effect of this is that your collection will now serialize as
<ArrayOfReport>
<Report>...</Report>
...
</ArrayOfReport>
Rather than what you wanted, which was:
<Reports>
<Report>...</Report>
...
</Reports>
To work around this you can specify an XmlRootAttribute() in the serializer.
See here for an example that combines the answer to your 2 most recent asks
(self-instantiation and serializing a CollectionBase):
http://www.winisp.net/cheeso/srcview...lectionBase.cs
Note that the copy in the parameterized constructor is different in this
code that in the prior code, because the "Items1" field is not used. So
here you gotta iterate to do the copy.
-D
Dino Chiesa
Microsoft Developer Division
d i n o c h @. OmitThis . m i c r o s o f t . c o m
"Greg" <Greg@.discussions.microsoft.com> wrote in message
news:59CCBFD6-29FB-40A1-9B9D-09F6A98A983E@.microsoft.com...
> I had a post very similar to this a week or so ago and I received a couple
good solutions ... unfortunately, I forgot to mention 1 point that
apparently makes a big enough difference so that the solution given won't
work. Here's what I originally posted (and below that is more info):
> I'm writing a class in C# ...
> I have a collection calls Reports made up of Report objects. I'm trying
to deserialize an XML file that looks like :
> <Reports>
> <Report>
> <Title>some title</Title>
> <Notes> some notes </Notes>
> </Report>
> <Report>
> blah blah blah
> </Report>
> </Reports>
> I want to be able to deserialize the file in the Reports collection
constructor and build the Report objects on the fly. The only examples I've
been able to find read the entire XML file outside of the class (which works
fine in my test console app), but I want to be able to be able to
dynamically build everything inside the collection class. Do I need to
parse through the XML file and got to each <Report> tag and deserialize one
Report at a time (and use "this.Add(newReport)")? How can parse the file
like that and pass just that info into the deserialize method? I haven't
used XPath, so if I need that, an example would really help.
> NOW..........................
> what I failed to mention was that my Reports collection implements
CollectionBase and now I recieve the following error: "XML attributes may
not be specified for the type TestCore.Reports"
> I remove the CollectionBase implementation and it works. I've found
several websites saying that I can deserialize a class implementing
CollectionBase, but I haven't found any examples or help as to what I'm
doing wrong. Here's what I have for the collection class using the solution
I received in my earlier post (if need be I can post more of my code):
> [System.Xml.Serialization.XmlRoot("Reports", Namespace="",
IsNullable=false)]
> [System.Xml.Serialization.XmlType("Reports", Namespace="")]
> public class Reports : CollectionBase
> {
> [System.Xml.Serialization.XmlElementAttribute
"Report",Form=System.Xml.Schema.XmlSchemaForm.Unqu alified)]
> public Report[] Items1;
> public Reports() {}
> public Reports(string path)
> {
> Reports temp= Reports.CreateFromString(path);
> Items1= temp.Items1; // shallow copy of array. Would need to do
this for each field in the RC type
> // "temp" now goes out of scope but the Items array gets
referenced by "this"
> }
> public static Reports CreateFromString(string xml1)
> {
> // could parameterize this with a filename, a stream, a string,
whatever
> XmlSerializer s1 = new XmlSerializer(typeof(Reports));
> // slurp it in: deserialize the original XML into a value
> System.IO.StringReader sr= new System.IO.StringReader(xml1);
> Reports rc= (Reports) s1.Deserialize(new
System.Xml.XmlTextReader(sr));
> return rc;
> }
> public int Add(Report report)
> {
> return List.Add(report);
> }
> public Report this[int index]
> {
> get
> {
> return((Report)List[index]);
> }
> set
> {
> List[index] = value;
> }
> }
> }
>