|
Wow. Many thanks to Mike for the great answers.
I've seen reference to Enterprise Manager in my SQL research but I don't think I have it. Unfortunately, I'm using MSSQL Desktop Edition (I think. The only GUI component I've seen runs in the systray and is called, "SQL Server Service Manager". I installed it from the SQL2000.msi package that gets installed with Visual Studio .NET Enterpise). How do I get a hold of Enterprise Manager? Many of the SQL solutions I find refer to it.
Many thanks,
-Ian
|
|
|
|
|
SQL Server Standard, Enterprise and Developer editions all have it. Also, the Evaluation edition that I posted a link to yesterday will have it also, that way you can down load the Evaluation and get to use it immediately (although if you are on a dial-up connection you may have to wait a while).
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Hi folks,
I'm looking to find some code, or guidance for producing my own code, which would give me a score (say a percent value) on how similar two strings are. Any ideas are appreciated.
Note: I've found, online, something about a Trigram algorithm for the purpose, but couldn't understand it fully. It seemed to be looking more at the meaning of two sentences (i.e. if they contain synonyms), which isn't quite what I'm looking for.
As an example, if my comparison sentence is: "I'm looking for a needle in a haystack" then I'd like "I'm looking for needles in a haystack" to give me a better score than "I'm looking for needles in haystacks", but the scores should be pretty close.
Thanks
R
|
|
|
|
|
Hi folks,
Well, there seems to be little interest in the subject. Either that, or I wasn't very clear on what I wanted - or, few people had what to say of instructive on the matter. No matter the case, in case anyone is looking for a solution, here is what I've found:
There is, amongst other things, a good article online (a university paper in fact) that is easy to understand, to the point, and free to download from here:
http://arxiv.org/abs/cs.DS/0112022 (See PostScript or PDF link at bottom)
Anyway, based on this very good document, I've written a C# function to compare two strings, and give a percentage on how close the strings are to one another as such:
// Found http://arxiv.org/abs/cs.DS/0112022
// July 6, 2004
// From: qi xiao yang
// Date (v1): Fri, 21 Dec 2001 05:58:12 GMT (250kb)
// Date (revised v2): Tue, 25 Dec 2001 21:29:22 GMT (294kb)
// Faster Algorithm of String Comparison
// Authors: Qi Xiao Yang, Sung Sam Yuan, Lu Chun, Li Zhao, Sun Peng
private double StringCompareValue(string str1, string str2)
{
string strX, strY; // smaller and bigger of the strings, respectively
double val; // return value
int window, wPos; // window width and position
double SSNC = 0; // value used to calculate return in the end
// get smaller & bigger strings sorted out
// also, perform lower case conversion
if(str1.Length < str2.Length)
{
strX = str1.ToLower();
strY = str2.ToLower();
}
else
{
strX = str2.ToLower();
strY = str1.ToLower();
}
// initialize
window = strX.Length;
wPos = 0;
// while the window exists and the smallest string exists
while(window > 0 && strX.Length > 0)
{
// while the window doesn't overlap the end of the string
while((wPos + window) <= strX.Length)
{
// get string to compare to
string comparer = strX.Substring(wPos, window);
// start comparison point at zero
int cPos = 0;
// loop through second string to get all possible comparisons
while(cPos + window <= strY.Length)
{
// if comparisons match
if(comparer == strY.Substring(cPos, window))
{
// update SSNC Value
SSNC += Math.Pow((2 * window), 2);
// remove "used characters"
strY = strY.Remove(cPos, window);
strX = strX.Remove(wPos, window);
// force window position to stay same place (moved forward again at end of loop)
wPos--;;
// continue search with next window position
break;
}
// move right on longer string
cPos++;
}
// move right on shorter string
wPos++;
}
// decrease window size - reset to beginning of string
window--;
wPos = 0;
}
// get percentage value
val = Math.Sqrt( (SSNC) / Math.Pow( (str1.Length + str2.Length) , 2) ) * 100;
return val;
}
If anyone finds this useful, you're free to use for any purpose, with the condition that the original article is referenced. I take no credit for the code, it is simply typing out the C# equivalent of the pseudo-code found in the article, which in turn is found free for use online.
If you have any comments, please post - I'm curious of your thoughts. Also, if there are any bugs in the code, let me know - I haven't tested too thoroughly.
All the best,
R
|
|
|
|
|
I've got a datagrid, and when the user double clicks to select a row, I want to bring up a new grid, in a dialog, with data based on the item selected. The CurrentCell property works fine until I click on a header to sort the grid, then it seems to continue to point to the cell that WAS in that location prior to the sort. How do I handle this ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
It's OK, I converted a VB.NET code example, and I've got it working. What the hell is a currency manager ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
It manages the current row in a data source and is used for data binding, as is the PropertyManager (both derivatives of the BindingManagerBase ).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hai there,
i already posted answer for this same query . so you can refer this message for further references.please read the discussion that held between me and the person who posted same queary posted some time earlier.
url : http://www.codeproject.com/script/comments/forums.asp?msg=821632&forumid=1649&Page=2&userid=854929&mode=all#xx821632xx
Please feel free to contact.
Sreejith S S Nair - Bangalore
|
|
|
|
|
Hello,
I'm a beginner reading "Microsoft Visual C# .NET Step By Step". I'm in Chapter 29, "Accessing Data with Web Forms". According to the author, I need to grant SQL access to the ASP.NET service by completing several steps, the first of which is:
In the command prompt window, type osql -E -S your_computer\NetSDK where your_computer is your computer name. This command starts the osql query tool, allowing you to enter SQL commands. You will see the prompt 1>.
I currently have MSSQLSever 2000 running in the systray. when I follow the above step, I get the following error message in the command prompt:
[DBMSLPCN]SQL Server does not exist or access denied.
[DBMSLPCN]ConnectionOpen >.
I've never used SQL before. I just installed it from the SQL2000.msi.
Thanks in advance!
-Ian
|
|
|
|
|
SQL Server actually runs as a Service. What you see in the Systray is the Service Manager which allows you to start, stop and pause the SQL Server service on the server you specify.
Check that the service is running.
Also, did you install your SQL Server as a named instance? That is what the "NetSDK" bit means - you can install SQL Server many times on a single machine. By default the installation will create an instance without a name. The Service Manager will probably list all the instances you have (I don't recall of the top of my head, and I am only running one instance that has no name)
Does this help?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Colin,
According to the SQL Server Service Manager, a SQL Server is running on my local machine. I installed MSSQL Server 2000 by running Program Files\Microsoft Visual studio .NET\FrameworkSDK\Samples\Setup\msde\setup\sql2000.msi. This installation package did not ask me to supply a server name.
When I removed the "NetSDK" bit, I got a different error:
Login failed for user 'IANANDKRISTA\Ian'.
|
|
|
|
|
Okay, you have at least established a connection to your SQL Server - but you also need to supply the correct userid and password. All SQL servers will have an "sa" account (System Admin) and if you haven't changed it then chances are its password will be blank.
Also, since your using MSDE (the Desktop Edition of SQL Server) you don't have all the nice GUI bits that make changing passwords, adding users and so on easy.
Once your logged in as sa, you need to run the query:
exec sp_grantlogin N'IANANDKRISTA\Ian'
Then you can log in automatically while you are logged into Windows.
Does this help?
Disclaimer: I use the Enterprise edition of SQL Server so I'm more used to the GUI which handles all this stuff - so, appologies in advance if I've missed something.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
How do I log in as the system administrator in order to run the query you suggest? Also, does the enterprise edition of SQL Server come with Visual Studio .NET? If not, where do I get it? (it sounds easier to use than the Desktop Edition, which I didn't even know I was running).
Thanks,
-Ian
|
|
|
|
|
According to the On-line help replacing the -E with -U sa from your original command line should do the trick.
Ian Bowler wrote:
Also, does the enterprise edition of SQL Server come with Visual Studio .NET?
The Enterprise edition is the version that is installed in companies' back-offices and is kind of expensive. The Developer Edition is identical except for the licence and maybe one or minor details. IIRC the Enterprise Edition must be run on a Server Edition of Windows, while the Developer Edition can run on a regular Windows 2000/XP machine.
The Developer edition also comes with some levels of MSDN subscription.
You can also download a 120-day trial version from Microsoft: http://www.microsoft.com/sql/evaluation/trial/default.asp[^] Which will give you everything you need. And it should be easy from the installation to name the server to fit with the examples in your book.
Does this help?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
You have been extremely generous with your time.
I have successfully logged in to the 'sa' account. However, I do have a security question now. I am going to post this question as a new topic.
Thank you so much for your help. Without your answers, I'd still be nowhere.
-Ian
|
|
|
|
|
Glad to help. Good luck learning about SQL Server.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
SQL Server and the MSDE can run up to 16 instances, inclusive. That's 16 total between the two, since SQL Server and the MSDE share the same engine.
The default installation for the MSDE that comes on the VS.NET CDs/DVD is not the default (unnamed) instance. Last time I checked, it was VSdotNET.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Dear, Sir and Madam.
Please see my code
public class Test
{
public string name;
public string title;
public Test[] Tests;
}
If I get an Test object (name = x) in Test object,
how to know the path of x?
Is there the better way than looping the object?
Sorry for bad English.
Thank You.
|
|
|
|
|
You just have to recurse and construct the "path" yourself. This would be a very simple recursive loop to create.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Dear, Sir and Madam.
To compare integer use the following code
if (i==j) //i and j is integer
DoSomething();
If i and j is MemoryStream, how to compare them
Sorry for bad English.
Thank You.
|
|
|
|
|
Only primitive types and those that define the equality operators are comparable using == , otherwise a simple reference (whether i and j referenece the same object) is performed. Classes may also override Object.Equals ; if they don't, again simple reference equality is used.
Since MemoryStream nor its base class, Stream , define either of these, you must compare these byte-for-byte yourself:
public int Compare(MemoryStream a, MemoryStream b)
{
if (a == null && b == null) return 0;
else if (a == null || b == null) throw new ArgumentNullException(
a == null ? "a" : "b");
if (a.Length < b.Length) return -1;
else if (a.Length > b.Length) return 1;
byte buf;
while ((buf = a.ReadByte()) >= 0)
{
int diff = buf.CompareTo(b.ReadByte());
if (diff != 0) return diff;
}
return 0;
} As with most comparisons in the BCL, 0 is returned if the two streams are equal. a negative or positive integer value is returned depending on the conditions, which should be obvious from the code above.
Note that this is only an example, but should give you an idea of how to compare the MemoryStream s.
You could also P/Invoke the memcmp function, although this will hinder the portability of your code but will be very fast.
As I covered a few days ago with the same question (hint: it's a good idea to try searching for previous questions before posting), you can P/Invoke memcmp like so:
public sealed class ByteComparer
{
private ByteComparer();
public static int Compare(byte[] a, byte[] b)
{
return memcmp(a, b, new IntPtr(a.Length)).ToInt32();
}
[DllImport("msvcrt.dll")]
private static extern IntPtr memcmp(byte[] a, byte[] b, IntPtr count);
} This does a comparison using the native memcmp API if you just pass two byte[] arrays (which you can get easily using MemoryStream.ToArray ) into the static method Compare :
MemoryStream a = ...;
MemoryStream b = ...;
int diff = ByteComparer.Compare(a.ToArray(), b.ToArray());
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
It might be worth adding:
if( a == b )
return 0; in case anyone does try to do Compare( a, a ) . It might seem unlikely, but you have to consider aliasing.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Good idea. Might save quite a bit of time since the byte for byte comparison would run max(O(n)) just to return 0.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
First of all, this is best suited for a good abstract model. A Person class, for example, would define the common properties and derivative classes (like Executive , Manager , etc.) would define additional properties specific to them (perhaps even extend Person with a Supervisor class, and the latter two classes derive from Supervisor since they would ultimately have something in common).
If you want the PropertyGrid to display properties at runtime that aren't actually defined on the class, implement the ICustomTypeDescriptor on your class. For the most part, just call TypeDescriptor methods for each interface member implementation, passing true for the parameter typically called noCustomTypeDesc . For example:
TypeConverter ICustomTypeDescriptor.GetConverter()
{
return TypeDescriptor.GetConverter(this, true);
} For the two ICustomTypeDescriptor.GetProperties overloads, you return a PropertyDescriptorCollection with the defined properties and shadowed properties.
You can find more information about the ICustomTypeDescriptor in the .NET Framework SDK, but implementing will require understanding the .NET ComponentModel, so I suggest you read Enhancing Design-Time Support[^] in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|