|
Hello
I have a string with data divided by a ":". I would like to take the data from before the ":" and set as object key in a hashtable, and take the data after the ":" and set as the object value in the same hashtable. What is the best way to go about achieving this?
/regards
|
|
|
|
|
The string class has a split method for doing this. Assuming there is only ever one :, this is the one to use. If it gets more complex than that, use a regular expression Searching for the index of : and doing your own substrings is messy, definately your last port of call
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I am having trouble using Stored Procedures. I am using C# .Net, and Visual Studio. In Visual Studio I created a 'SqlDataAdapter' and then generated a Stored Procedure which I will include as well a
s the code that I am trying use to call the procedure. Can someone get me ontrack!!;)
Thanks Norm
private void Save_Click(object sender, System.EventArgs e)
{
sqlUpdateCommand1.Connection = sqlConnection1;
if (sqlConnection1.State != ConnectionState.Open)
sqlConnection1.Open();
SqlCommand cmd = new SqlCommand("InsertCommandServices");
cmd.CommandType = CommandType.StoredProcedure;
SqlParameterCollection pc = cmd.Parameters;
pc.Add("[service-code]",SqlDbType.Int, 4, txtServiceCode.Text);
pc.Add("[service-description]",SqlDbType.Char, 30, txtSeviceDesc.Text);
pc.Add("[large-animal-cost]",SqlDbType.Money, 8, cbLargeAnimalCost.Text);
pc.Add("[service-description]",SqlDbType.Money, 8, cbMediumAnimalCost.Text);
pc.Add("[service-description]",SqlDbType.Money, 8, cbSmallAnimalCost.Text);
}
IF EXISTS (SELECT * FROM sysobjects WHERE name = 'InsertCommandServices' AND user_name(uid) = 'dbo')
DROP PROCEDURE [dbo].[InsertCommandServices];
GO
CREATE PROCEDURE [dbo].[InsertCommandServices]
(
@Param11 int,
@Param12 char(30),
@Param13 money,
@Param14 money,
@Param15 money
)
AS
SET NOCOUNT OFF;
INSERT INTO services([service-code], [service-description], [large-animal-cost], [medium-animal-cost], [small-animal-cost]) VALUES (@Param11, @Param12, @Param13, @Param14, @Param15);
SELECT [service-code], [service-description], [large-animal-cost], [medium-animal-cost], [small-animal-cost], [service-nbr] FROM services WHERE ([service-nbr] = @@IDENTITY);
GO
|
|
|
|
|
NormBohana wrote:
service-code
Put an @ in front of variable names
NormBohana wrote:
@Param11
Use those nice names here, instead of this meaningless stuff.
Looks OK otherwise. Why on earth are you selecting back the stuff you stuffed in ? Why not return something useful, like @@IDENTITY ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks Christian, Visual Studio generated the stored procedures like they are. I added the '@' to the variables, and the code runs but nothing is stored in the database. Do you have anyother ideas, I am stuck at this point. I am doing more research into the problem so any help that I can get will help.
Norm
|
|
|
|
|
Can you run the stored procedure in query analyser ? If you can, and it works, then the problem is in your code ( the SP looks fine to me, but you should check to be sure )
Also, have you stepped through to see if the code branch where it checks if the connection is open succeeds ? I don't see any code to notify you if the problem is that the connection is closed.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian, I can run the stored procedure in the sql analyzer, and its runs. I have since found out that my code was wrong. I have rewritten the code and here it is. I cannot find an example of what to in the datareader. Cannot you direct me to some doc. that I can use, it would help. I have purched Microsoft ADO.net its close but no example on how to use a insert stored procedure. Thanks
Norm
try
{
sqlUpdateCommand1.Connection = sqlConnection1;
if (sqlConnection1.State != ConnectionState.Open)
{
sqlConnection1.Open();
}
SqlCommand cmd = new SqlCommand("InsertCommandService");
cmd.CommandType = CommandType.StoredProcedure;
SqlParameterCollection pc = cmd.Parameters;
pc.Add("[@service-code]",SqlDbType.Int, 4);
pc.parameters[0].value = txtServiceCode.Text;
pc.Add("[@service-description]",SqlDbType.Char, 30);
pc.parameters[1].value = txtServiceDesc.Text;
pc.Add("[@large-animal-cost]",SqlDbType.Money, 8);
pc.parameters[2].value = cbLargeAnimalCost.Text;
pc.Add("[@medium-animal-cost]",SqlDbType.Money, 8);
pc.parameters[3].value = cbMediumAnimalCost.Text;
pc.Add("[@small-animal-cost]",SqlDbType.Money, 8);
pc.parameters[4].value = cbSmallAnimalCost.Text;
SqlDataReader rdr = pc.ExecuteReader();
if (rdr.Read())
{
}
this.Close();
|
|
|
|
|
NormBohana wrote:
pc.Add("[@small-animal-cost]",SqlDbType.Money, 8);
Lose the square brackets. Where did they come from ? I dunno why I didn't see that before.....
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello...
I'm trying to track the time for a user who login from Active directory in a domain controller. I'm having a problem with in which I don't know how to do that actually in real time, so that controlling the access of the user say about 10 hours only, after that the account will be disabled, I don't want that the user use these hours sequentially, but in a whatever manner he wants it, I mean login say for 5 hours then he logout, so my counter should check the remaining time for him , and if the total time is 10 hours the remaining time for him is 5 hours, so when he access again the domain controller he has only 5 hours remaining.
Can you help me with this problem, please.
Or if you know anyone who can help me with this problem or any articles discuss this problem.
Thanks in advance.
|
|
|
|
|
How can i do to replace Html Tag
For example in my project when i input <br> or <p> the error message will display
Could you can write an function in C# to replace the HTML Tag
Thanks for helping.
I tried so hard and got so far
|
|
|
|
|
You can make a function that replaces all the ( < ) tags with (_&_l_t_;_)(<)
and the closing tag( > ) with (_&_g_t_;_). (>)
Note:
You must remove the underscore character (_) from all the codes.
|
|
|
|
|
If you need an HTML-Encoded string you can use the System.Web.HttpUtility.HtmlEncode function.
You must reference the System.Web assembly to use this function.
If you need to actually strip the Html tags you coud use a regular expression like this:
string cleanedText = System.Text.RegularExpressions.Regex.Replace(htmlString,@"(?:</?(br|p)[^>]*>)","\r\n");<br />
cleanedText = System.Text.RegularExpressions.Regex.Replace(cleanedText,@"(?:<[/!]?([A-Z][A-Z0-9]*)[^>]*>)","");
This code is very basic. It will not strip scripts nor will it handle tables pretty well.
I hope this is at least a start for you.
|
|
|
|
|
Is there a ActiveX of Autocad for C#.NET? Thank you.
|
|
|
|
|
If Autocad exposes a COM object, you can import it into C# and call it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
Read the docs ? Google ? Look for samples that came with it ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
There is CADIO (search for DXF on the site).
It is for unmanaged C++ so does not work directly in C#
|
|
|
|
|
AutoCAD 2005 and 2006 have managed assemblies you can use. Otherwise you can ActiveX interface that AutoCAD has supported since AutoCAD 2000.
--
Joel Lucsy
|
|
|
|
|
Thank you for u answer but please give me some example.
|
|
|
|
|
I might be able to, but you didn't say what version of AutoCAD you had, what approach you'd like to take, nor the scope of what you're trying to attempt.
--
Joel Lucsy
|
|
|
|
|
I have autocad 2006. I want to develop my application can view AutoCad File (DWG) with some feature like zoom-in zoom-out.
|
|
|
|
|
It sounds like you're trying to create a viewer external to AutoCAD. This isn't really possible without licensing specific things from AutoDesk.
--
Joel Lucsy
|
|
|
|
|
So I'm making an application that alters another Windows program. I want to do it buy synthesizing mouseclicks. I have that aspect working, what I need to do now is determine the location. I'm using GetWindowLocation, However the values it returns are kind of absurd. SO I'll post my code(stolen mostly from another post) and if anyone can figure out where I went wrong...
<br />
[DllImport("user32.dll")]<br />
private static extern bool GetWindowPlacement(IntPtr hWnd, ref WindowPlacement placement);<br />
public struct WindowPlacement{<br />
public uint length;<br />
public uint flags;<br />
public uint showCmd;<br />
public POINT ptMinPosition;<br />
public POINT ptMaxPosition;<br />
public RECT rcNormalPosition;<br />
}<br />
public struct POINT{<br />
public long x;<br />
public long y;<br />
}<br />
public struct RECT{<br />
public long left;<br />
public long top;<br />
public long right;<br />
public long buttom;<br />
}
That's my structure definitions.
I call it like this
<br />
WindowPlacement Place;<br />
GetWindowPlacement(Handle, ref Place);<br />
Ok so there it is, the values return seem pretty absurd. Negative numbers 15 digits long and such, nothing I can make a mousepointer move to without errors. Anyhelp would be great.
jake
|
|
|
|
|
In C++, a long and an int are both the same size. Change the longs to ints in POINT and RECT, and the rcNormalPosition will become valid and accurate, I've just tested it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hi
how i can make a stand alone c# windows application?
thanks
|
|
|
|
|