|
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?
|
|
|
|
|
The problem are the static items in the Items property on design-time.
Just go to your form design->select a pcaTimePicker->Properties->Items delete everything in it.
After that you should not have any problems.
The problem are the following lines in the designer-file:
this.pcaTimePicker3.FormattingEnabled = true;
this.pcaTimePicker3.Items.AddRange(new object[] {
"12:00 ",
"12:30 ",
"1:00 ",
"1:30 ",
"2:00 ",
"2:30 ",
...});
this.pcaTimePicker3.Location = new System.Drawing.Point(101, 243);
this.pcaTimePicker3.Name = "pcaTimePicker3";
this.pcaTimePicker3.Size = new System.Drawing.Size(121, 21);
this.pcaTimePicker3.TabIndex = 5;
Those lines get called after your pcaTimePicker first invokes Repopulate(...).
Here some example:
public Form1()
{
InitializeComponent();
MessageBox.Show(pcaTimePicker3.Items.Count.ToString());
pcaTimePicker3.Items.Clear();
pcaTimePicker3.Increment = 30;
MessageBox.Show(pcaTimePicker3.Items.Count.ToString());
}
Hope I could help you.
Greetings
Covean
|
|
|
|
|
BRILLIANT, Covean!!! I never would have thought of looking at the designer file. That started me thinking that there has to be a way to prevent design-time population. At first I just tried adding a check against the ComboBox.DesignMode property. However, RepopulateChoices() is also called from the constructor, and DesignMode doesn't register that early. On the other hand, if I removed the call from the constructor, then nothing was populated at run-time. My final solution was:
1. Remove the call to RepopulateChoices() from the constructor.
2. Override the InitLayout method like this:
protected override void InitLayout()
{
base.InitLayout();
if (DesignMode) return;
RepopulateChoices();
}
That prevents any items from being populated at design time and still populates the ComboBox at run-time with exactly ONE set of data.
Thanks again.
|
|
|
|
|
|
And 5 for the answer seeing as OP forgot!
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Thank you.
Greetings
Covean
|
|
|
|
|
if any one know then please help me ....
|
|
|
|