|
Greetings
I want to build a windows application that can connect to a webserver to get user authentication. Just like any IM msngr. We install the windows application and later it connects to internet to get authentication. How can I make such application???
Plz help.
modified on Wednesday, January 20, 2010 2:06 PM
|
|
|
|
|
Can anyone tell me why when writing code to open a file you use a forward slash in the path name instead of a back slash as in the following:
private void button1_Click(object sender, EventArgs e)
{
string file_name = "C:/test1.txt";
System.IO.StreamReader objReader;
objReader = new System.IO.StreamReader(file_name);
textBox1.Text = objReader.ReadToEnd();
objReader.Close();
}
|
|
|
|
|
Because it's easy to type!
In this case the slash ("/") and backslash ("\") are both understood as the delimiter for path, so either one should work. However, backslash is used to escape in string literals, so to use backslash, you should escape it, like so: \\. You can see that is more typing than using just slash.
If you have a lot of backslashes in your string literal, you can put @ in front of it so you don't need to escape them. For example,
string file_name = @"C:\test1.txt";
Still, there is the character @ you have to type. It's still more typing than simply using the forward slash.
|
|
|
|
|
Thanks
|
|
|
|
|
My guess is that it's simply a cheat to avoid having to type the requisite double backslash (special character):
string file_name = "C:\\test1.txt";
...Byte conservation; it's one byte shorter in the source file.
|
|
|
|
|
Thanks That's the problem with using tutorials...nobody around to answer the howcomes.
|
|
|
|
|
Darrall wrote: string file_name = "C:/test1.txt";
Because it works . It transforms into "C:\\test1.txt";
But I don't. I use either
@"C:\test1.txt";
"C:\\test1.txt";
|
|
|
|
|
Thanks
|
|
|
|
|
Reading this article might give you some more information.
Now...bring me that horizon. And really bad eggs...Drink up me hearties, YO HO!
|
|
|
|
|
|
Hi all
In my program i want to get image from users and insert it into mydatabase .
Now i want to know how can i insert image into database?
Thx alot for your attention.
|
|
|
|
|
You can conduct a search on "blob and database". An image can be treated as a blob (binary large object). Database tables can have blob fields. They can be used to hold images.
|
|
|
|
|
Thx for your reply.
I can't understand your answer.
I want to insert an image to sql server database.
How can i do it?
|
|
|
|
|
|
Hi!
I am trying to deploy the application on Windows CE 6.0 platform. However, when it comes to connection to SQL Server on my laptop it "thinks" for a while and I receive the following error:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Windows.Forms.dll
Additional information: SqlException
I tried to find out the root of the problem and found out that my code
static string connectionString = "Data Source=192.168.2.132; Initial Catalog=MDetectorDatabase; Integrated Security=true";
private void SubmitButton_Click(object sender, EventArgs e)
{
string login = this.loginTextBox.Text;
string passw = this.passwTextBox.Text;
string user = "";
SqlConnection loginConnection = new SqlConnection(connectionString);
string loginquery = "SELECT * FROM Doctors Where UserName='" + login + "';";
SqlCommand loginCommand = new SqlCommand(loginquery, loginConnection);
loginConnection.Open();
SqlDataReader loginReader = loginCommand.ExecuteReader();
...
}
broke on loginConnection.Open(); line showing the problem 'loginConnection.ServerVersion' threw an exception of type System.InvalidOperationException'
Does anybody know how to fix this problem?
|
|
|
|
|
Hello all,
I am having a problem when trying to load a dataset with xml using ReadXml or ReadXmlSchema methods. The error I get is "DataSet doesn't allow the circular reference in the ComplexType named 'EDElementType'". The xml is below.
I think it is due to the fact that the complex type EDElementType contains a element named 'children' of type EDElementType which would cause a 'circular reference'. Any ideas how I can fix this?
Thanks in advance.
Xml:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:cbe="http://www.abccorp.com/cbe" targetNamespace="http://www.abccorp.com/cbe" version="1.0.1" elementFormDefault="qualified">
<xsd:complexType name="CBEType">
<xsd:sequence>
<xsd:element name="edElements" type="cbe:EDElementType" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="CBE" type="cbe:CBEType" />
<xsd:complexType name="EDElementType">
<xsd:sequence>
<xsd:choice>
<xsd:element name="values" minOccurs="1" maxOccurs="unbounded">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="1024"></xsd:maxLength>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="hexValue" type="xsd:hexBinary" minOccurs="1" maxOccurs="1" />
</xsd:choice>
<xsd:element name="children" type="cbe:EDElementType" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
|
|
|
|
|
I like going the reverse direction when creating a Data Set for use with MS tools. Ie, create a data set in code using the object methods to assign types and relationships and then save the Data Set to an XML file. You will then have a sample Data Set that MS will support.
|
|
|
|
|
I ended up using xsd.exe, which worked. Go figure.
|
|
|
|
|
Hi, i have the following question. When i add a control to my form it gets some automatic code in the InitializeComponents method in Designer.cs. When i delete the control from my form the code will still be there. Is there an automatic way to remove the unused control declarations from InitializeComponents?
TY
|
|
|
|
|
Try building using "clean" then "rebuild".
|
|
|
|
|
That did not work... Any other ideas?
|
|
|
|
|
|
|
My last post about this issue resulted in a lot of confusion. So I want to try this a different way:
I'm making a custom time picker that inherits directly from ComboBox. I am not using a designer to make a System.Windows.Forms.UserControl-based control. I will post the full code in a moment to clarify.
The control has a property called Increment, which is the increment in minutes between each ComboBox item. Therefore the "set" action of Increment invokes the private method RepopulateChoices(). The method is also invoked in the "set" action of another property called ShowMilitary. The first line of RepopulateChoices() is:
<br />
Items.Clear();<br />
Remember I'm inheriting directly from ComboBox, so this syntax is CORRECT. It does not need to be prefixed by "myComboBox1." or anything like that. It is not a designer-based user control.
The problem is that I end up with duplicate items. Example: If I set Increment = 30, I'll see the items 11:00 PM, 11:30 PM, and then 12:00 AM, 12:30 AM and it keeps going. The number of duplicates depends on the nesting of containers, adding 2 days' worth of entries for every layer:
Dropped directly on a form: 96 entries (2 days @ 30 minute increments)
Dropped in a panel on a form: 192 entries (4 days)
Dropped in a panel in a TableLayout cell on a form: 288 entries (6 days)
It's like Items.Clear() is failing to do anything. I'm trying to figure out why. Here is my complete class code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;
using System.Drawing;
namespace PCA.SecureWinCtrls
{
[Description("Control for displaying a time selection combox box with custom time increments. Includes provision for PCA securiyt model."),
ToolboxBitmap(typeof(ComboBox))]
public sealed class pcaTimePicker : ComboBox
{
#region MEMBERS
[Browsable(false)]
public new ComboBoxStyle DropDownStyle
{
get
{
return ComboBoxStyle.DropDown;
}
}
[Browsable(false)]
public int Hours
{
get
{
if (ShowMilitary)
return MilHours;
int i = MilHours;
if (i > 12)
return i - 12;
else if (i == 0)
return 12;
else
return i;
}
}
[Browsable(false)]
public int MilHours
{
get
{
ValidateValue(true);
return DateTime.Parse(Text).Hour;
}
}
[Browsable(false)]
public int Minutes
{
get
{
ValidateValue(true);
return DateTime.Parse(Text).Minute;
}
}
private bool mbMilitary = false;
[Description("Gets/sets whether the control shows time as a 24-hour clock."),
DefaultValue(false)]
public bool ShowMilitary
{
get { return mbMilitary; }
set
{
mbMilitary = value;
RepopulateChoices();
}
}
private int miIncrement = 30;
[Description("Gets/sets the increment value in minutes. Valid values are 10 - 720."),
DefaultValue(30)]
public int Increment
{
get { return miIncrement; }
set
{
if (value < 10 || value > 720)
{
throw new Exception("Increment value must be a value in minutes ranging from 10 to 720 (12 hours).");
}
miIncrement = value;
RepopulateChoices();
}
}
#endregion
#region EVENT HANDLERS
[Description("Event fired when the control loses focus and the text value cannot be parsed as time.")]
public event EventHandler ValidationFailed;
public event EventHandler ValidationSucceeded;
#endregion
#region PUBLIC METHODS
public pcaTimePicker() : base()
{
base.DropDownStyle = ComboBoxStyle.DropDown;
base.Leave += new EventHandler(this_Leave);
RepopulateChoices();
}
public void ForceValidation(bool bCauseException)
{
ValidateValue(bCauseException);
}
#endregion
#region PRIVATE METHODS
private void RepopulateChoices()
{
Items.Clear();
int i = 0;
while (i < 1440)
{
DateTime dat = new DateTime(1, 1, 1, i / 60, i % 60, 0);
if (ShowMilitary)
Items.Add(dat.ToString("HH:mm"));
else
Items.Add(dat.ToString("h:mm tt"));
i += Increment;
}
}
private void ValidateValue(bool bOnPropertyAccess)
{
bool bOK = true;
try
{
DateTime.Parse(base.Text);
}
catch (Exception)
{
bOK = false;
if (ValidationFailed != null)
{
ValidationFailed(this, null);
if (bOnPropertyAccess)
throw;
}
else
throw;
}
if (bOK && ValidationSucceeded != null)
ValidationSucceeded(this, null);
}
#endregion
#region EVENT HANDLERS
private void this_Leave(object sender, EventArgs e)
{
ValidateValue(false);
}
#endregion
}
}
|
|
|
|
|
I should add that when I step-trace through RepopulateChoices() everything seems fine. When I exit the method and hit F5 to continue, my breakpoint is no longer encountered but I still end up with duplicate items. That's what is making this so darn frustrating.
|
|
|
|
|
I get your problem now. There's no way that the Items.Clear() doesn't work.
The problem might be from drawing(paint event(s)).
Ex: you drop your control on the form. The Ctor calls the RepopulateChoices.
Then the paint event is raised and ads the items once again.
Drop on a panel on a form. Form invalidate=> your control invalidate.
Panel invalidate again => your control invalidates.
That's the only reason that I could think of.
But it might not be this at all.
Do you override the OnPaint?
|
|
|
|