c#-2.0

Problem in generating random number [duplicate]

女生的网名这么多〃 提交于 2019-12-02 11:24:08
问题 This question already has answers here : Closed 9 years ago . Possible Duplicate: Why does it appear that my random number generator isn't random in C#? Dear friends I want to generate 4 random number between 1 - 55 ,but the problem is that most of the time I receive 2 number same :( for example the generated number is 2 2 5 9 or 11 11 22 22! I dont know why? I use : Random random = new Random(); return random.Next(min, max); for generating my random number. I put them in a While for

Taking a screenshot using c# with out including task bar.

痞子三分冷 提交于 2019-12-02 07:51:07
How to take screenshot using c# with out including task bar.I tried some codes but it takes whole screen. try with Screen.PrimaryScreen.WorkingArea it gives you the screen excluding task bar Bitmap bmpScreenshot = new Bitmap(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height, PixelFormat.Format32bppArgb); Graphics gfxScreenshot = Graphics.FromImage(bmpScreenshot); gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.WorkingArea.X, Screen.PrimaryScreen.WorkingArea.Y, 0, 0, Screen.PrimaryScreen.WorkingArea.Size, CopyPixelOperation.SourceCopy); bmpScreenshot.Save(

error CS0103 in ASP.NET

▼魔方 西西 提交于 2019-12-02 07:43:50
Hello when I compile a ASP.NET C# project using file Microsoft.NET\Framework\v2.0.50727\MSBuild.exe I am getting an error as "ERROR CS0103: The name (forms name) cannot be found in the current context" This error is displayed individually for every where I use ASP.NET forms. As seen in the MSDN An attempt was made to use a name that does not exist in the class, namespace, or scope. Check the spelling of the name and check your using statements and assembly references to make sure that the name you are trying to use is available. One common mistake is to declare a variable within a loop or a

AutoComplete Texbox error - write to protected memory

旧巷老猫 提交于 2019-12-02 06:07:58
问题 I have an autocompleate textbox that looks into a data base. Some times while I'm typing I received the following error. Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Here is the code private void tBSearchName_TextChanged(object sender, EventArgs e) { try { //test length if (tBSearchName.Text.Length > 3) { //prevent db lookups if (!tBSearchName.Text.ToLower().Contains(oldName) || oldName == String.Empty) { //test for a name + first

how to make search of a string in a data base in c#

十年热恋 提交于 2019-12-02 04:48:35
This is the code that is used to make the search private void button1_Click(object sender, EventArgs e) { string connectionString = Tyre.Properties.Settings.Default.Database1ConnectionString; SqlConnection conn = new SqlConnection(connectionString); DataTable dt = new DataTable(); SqlDataAdapter SDA = new SqlDataAdapter("SELECT * FROM table1 where Nom like " + textBox1.Text, conn); SDA.Fill(dt); dataGridView1.DataSource = dt; } and im getting this error An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll Additional information: Invalid column name

how to compare two dates in datetimepicker

眉间皱痕 提交于 2019-12-02 03:21:57
I am doing Windows project, in which I have two DateTimePicker controls, one for StartDate and other for EndDate. In runtime, when user selects the StartDate and EndDate from that controls, it should read the textfile(i.e) log.txt & search line by line get the matching of both these dates and as well as in between dates and write the data to a textbox or label control for eg in log file, data is like below: 3/12/2013 2:51:47 PM - ASDASDASD.D20131203145019 4/12/2013 2:52:23 PM - ASDDFSDSA.C20131203145019 5/12/2013 2:52:37 PM - SDASAFAS_20131203182101.D 6/12/2013 3:17:11 PM - RRRTWEWA

Launch C# .Net Application from C++

大兔子大兔子 提交于 2019-12-02 03:13:01
问题 Is it possible to launch a C#.Net (2.0) application from an application written in C++??? Thanks, EDIT: Cool - so I just have to know where the app is: LPTSTR szCmdline = _tcsdup(TEXT("C:\\Program Files\\MyApp -L -S")); CreateProcess(NULL, szCmdline, /* ... */); 回答1: You can launch any EXE using CreatePocess or ShellExecute API. ( including C#.Net) 回答2: Yes - for example using system function or CreateProcess \ CreateProcessW \ CreateProcessA [or fork + exex if you use *nix + mono] 来源: https:

Enterprise Library 3.1 Logging Formatter Template - Include URL Request

∥☆過路亽.° 提交于 2019-12-02 02:44:59
问题 We have a custom web app built using Ektron v8.0 which uses EL 3.1 and the format template in the logging config is configured as such: <add name="Text Formatter" type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging" template="Timestamp: {timestamp} Message: {message} Category: {category} Priority: {priority} EventId: {eventid} Severity: {severity} Title:{title} Extended Properties: {dictionary({key} - {value} )}" /> Is

Launch C# .Net Application from C++

陌路散爱 提交于 2019-12-02 02:24:51
Is it possible to launch a C#.Net (2.0) application from an application written in C++??? Thanks, EDIT: Cool - so I just have to know where the app is: LPTSTR szCmdline = _tcsdup(TEXT("C:\\Program Files\\MyApp -L -S")); CreateProcess(NULL, szCmdline, /* ... */); You can launch any EXE using CreatePocess or ShellExecute API. ( including C#.Net) Yes - for example using system function or CreateProcess \ CreateProcessW \ CreateProcessA [or fork + exex if you use *nix + mono] 来源: https://stackoverflow.com/questions/2843248/launch-c-sharp-net-application-from-c

AutoComplete Texbox error - write to protected memory

依然范特西╮ 提交于 2019-12-02 01:58:38
I have an autocompleate textbox that looks into a data base. Some times while I'm typing I received the following error. Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Here is the code private void tBSearchName_TextChanged(object sender, EventArgs e) { try { //test length if (tBSearchName.Text.Length > 3) { //prevent db lookups if (!tBSearchName.Text.ToLower().Contains(oldName) || oldName == String.Empty) { //test for a name + first letter of last name if (Regex.IsMatch(tBSearchName.Text, @"(\w)+\s(\w)+(\.)*")) { tBSearchName