|
Are you just trying to ruffle feathers? What is the point of this posting?
feedscrn wrote: Maybe the VB portion redeems it from the doldrums...?
'Maybe' being the imperative word.
Josh
|
|
|
|
|
After reading more.. C# really is not connected to C++ in any way. So many things in programming are either built onto C++ or the C++ name... using the popularity of C++ to its advantage (and confusing C++ programmers at the same time).
Take Care
God Bless... Feedscrn
+------------------------------+
| The screen is hungry, Feed It! |
+------------------------------+
|
|
|
|
|
Hello,
I am using the following piece of code to save data to my database:
<br />
SqlDateTime date = DateTime.Now; <br />
SqlCommand myCommand2 = new SqlCommand("INSERT INTO orders (date,customerid,productid,sum) VALUES ('" + date + "'," + index + ",'" + productid + "','" + aantal + "')", connect); <br />
myCommand2.ExecuteScalar();<br />
the date-field in the database has the property datetime.
When i try to run the query, he always gives following error:
<br />
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.rnThe statement has been terminated.<br />
I tried to use DateTime.Now directly in the query, but it still gives the same error, also writing a date by hand (in the values-field in the query) gives an error.
When I write a date (exactly the same format as the one above) directly in the database (without a query), i have no errors what so ever.
Can somebody help?
Thanks!
|
|
|
|
|
Have you had a look at at the actual SQL string produced by your string concatenation? I'm guessing there's a format mismatch, maybe due to some regional settings or something. (Often a problem when putting datetimes into the db like this.)
A safe and easy way to fix this would be to use parameters in your SQL query:
string query = @"
INSERT INTO orders (date,customerid,productid,sum)
VALUES (@date, @customerid, @sum)
";
SqlCommand cmd = new SqlCommand(query, con);
cmd.Parameters.Add("@date", DateTime.Now);
cmd.Parameters.Add("@customerid", customerid);
cmd.Parameters.Add("@sum", sum);
cmd.ExecuteNonScalar();
|
|
|
|
|
Thanks, that solved my problem!
|
|
|
|
|
SqlServer likes to see a char dates in a specfic format. You will have to experiment a little but from memory it likes:
01/01/98
OR
01/01/98 23:59:59.999
It is not very tolerant with other formats.
Try date.ToString("dd/MM/yyyy HH:mm:ss.000") in place of date
BTW: I normally let the SQL Server set a DateTime stamp by using GetDate() in place of '" + date + "' . It will usually have a more accruate time then a workstation (at least it will be a common clock). There is also GetUTCDate() for when your users are in different time zones.
|
|
|
|
|
Michael Potter wrote: Try date.ToString("dd/MM/yyyy HH:mm:ss.000") in place of date
date.ToString("s"); works for me as well. This put a "T" between the date and the time, but that seems to be accepted by MySQL in my case.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I have written a function called MyFunction() in a class library called TestClassLibrary. Now supppose that at design time a user creates an object of this class and presses dot(.) with the object to view the related functions, properties etc in the auto context menu. I want that whenever the user selects MyFunction() in that auto context menu, a little description of MyFunction() is displayed as tooltip as it appears with the built in functions. How to do that?
Thanks in advance
|
|
|
|
|
You need to apply a 'Description' attribute to the function. Here is an example:
[Description("Override this method if anything needs to be saved other than the ActivePanel.")]
public virtual bool CanClose()
{
if (this.ActivePanel != null)
return ActivePanel.CanClose();
else
return true;
}
|
|
|
|
|
You don't need to use the Description attribute, as mentioned in the other reply. That attribute will provide the text shown in the property grid for a property. What you are looking for is XML comments. Use the triple-slash comments on your method. Then:
1)Open the Property Pages for your class library project in Visual Studio.
2) Click 'Configuration Properties' and then 'Build' in the TreeView on the left.
3) You'll see under the 'Outputs' section a property called 'XML Documentation File'. Set that value to <AssemblyName>.xml (where AssemblyName is the name of the assembly). For example, if your assembly is foo.dll then call your XML file foo.xml
That will cause your XML comments to be included in an output file generated every time you build. Consumers of your DLL should put that XML file in the same directory which contains the DLL, so that while using your types they'll get IntelliSense w/ your comments.
Josh
|
|
|
|
|
That's good to know. Curious though ... using the Description attribute has worked for me in the past ...
|
|
|
|
|
I learned something new, too. I never knew that the Description attribute was used by Visual Studio's code editor. I wonder if there is a way to express parameter-level information using attributes, instead of triple-slash comments. That would be handy for creating thoroughly self-describing components.
Thanks for the info
Josh
|
|
|
|
|
I have a loop in which I'm populating a form. I try to click a button called "Abort" to terminate the loop but I can't until the loop ends by itself. How can I fix this?
|
|
|
|
|
|
Background:
I'm taking a query from an Oracle Database into a DataSet. Then taking a query from an SQL Database into another Dataset. Merging the 2 datasets, and running the DataAdapter Update. The goal is to keep the Oracle and SQL database tables in sync, and to know what (if any) rows get added/deleted/modified. The issue I'm having is, the Update will update ALL the rows with the same information, or none of the rows even if there are changes. Some additional info, the Oracle Table and the SQL Table don't exactly match, but the Keyed fields are the same (the SQL table has some custom added flags and such). When I do the select, I ONLY select the like fields, in the correct order, and cast the Oracle column Names to be like the SQL column names.
<br />
SqlDataAdapter regionDa = new SqlDataAdapter(regionSql, _sConn);<br />
DataSet regionDs = new DataSet();<br />
<br />
regionDa.UpdateCommand = updCmd;<br />
regionDa.InsertCommand = insCmd;<br />
<br />
OracleDataAdapter oDa = new OracleDataAdapter(oSql, _oConn);<br />
DataSet oDs1 = new DataSet();<br />
<br />
regionDa.Fill(regionDs);<br />
oDa.Fill(oDs1);<br />
<br />
regionDa.FillSchema(oDs1, SchemaType.Source);<br />
regionDa.FillSchema(regionDs, SchemaType.Source);<br />
<br />
regionDs.Merge(oDs1);<br />
<br />
regionDa.Update(regionDs, regionDs.Tables[0].TableName);<br />
Any help would be greatly appreciated.
Thanks!
Scott
|
|
|
|
|
Good day everyone,
I need to do a Login system in ASP.Net using C#.Net as code behind page for my website.
I've got an Access database conntaining username and password.
Is there anyone know where can I find a sample project?
If you're interested in, pls help
Thanks so much.
eric
|
|
|
|
|
Please dont crosspost - this belongs in ASP.NET where you have already posted it!
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
The code snippet:
namespace PrintForm
{
public partial class Form1 : Form
{
public Form1(string urlToPrint)
{
InitializeComponent();
webBrowser1.Url = new Uri(urlToPrint);
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
webBrowser1.Print();
webBrowser1.Dispose();
Application.Exit();
}
}
}
I get an error :
RaceOnRCWCleanup was detected
Message: An attempt has been made to free an RCW that is in use. The RCW is in use on the active thread or another thread. Attempting to free an in-use RCW can cause corruption or data loss.
The error occurs on the webBrowser1.Dispose call.
Using VisStudio 2005
If I put up a message box right after the webBrowser1.Print() call, my document does get printed. I dont see any event handling of printing so theres nothing I can pend on (IsBusy returns false, its apparently only valid for navigation, not useable during printing)
Ideas?
Thanks!
|
|
|
|
|
hi,
i need to design survey software using c#.net. this software will desing survey. all the information of survey will be store in xml file (questions, answeres, type of question...). i would like to know if there is any code on net that i could take look or anyone can help me where to start.
Thanks,
|
|
|
|
|
ap_sa wrote: i need to design survey software using c#.net. this software will desing survey
Looks like an infinite loop to me.
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
If MFC code is as follows:
//*CODE SNIPPET - START*
long newtime = 1136710800;
CTime tm(newtime);
str = tm.FormatGmt("%d %m %Y\n%H:%M:%S");
//*CODE SNIPPET - END*
At the execution of last line, 'str' contains as "1/8/2006 9:00:00 AM".
//Question
HOW CAN I REPRODUCE THIS CODE IN C#?
I'll be very thankful if replied at the earliest.
-Kiran
|
|
|
|
|
System.DateTime contains the same capacity as CTime to be constructed from a value and then use the ToString() method to format into a string.
However the underlying values are different. CTime uses seconds since January 1, 1970 while DateTime uses a unit (tick) smaller than a second and starting at January 1,1. So you can't use a CTime value to initialize a DateTime value unless you convert it first.
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
hi everybody, i'm new in this, i wanna know if somebody knows how can i block the hot keys of excel, word or another program like this , i open these kind of files from c#, is it possible? . Ahm i'm sorry for my bad english jejeje. Thank's everybody!!!
|
|
|
|
|
I am using a statusstrip control in C#, and I am trying to place a ToolStripLable. I want this label to appear at the right end of statusstrip, Can anyone please tell me how to do this?
thanks,
arti
|
|
|
|
|
Put 2 labels on the statusstrip and set the "Spring" property of the left one to "true". That will push the one on the right out to the end of the strip.
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|