|
when i am inserting data by inline sql then i am getting error like
Server: Msg 241, Level 16, State 1, Line 1
Syntax error converting datetime from character string.
and my inline sql is :-
INSERT INTO MShift (DayName,ShiftDate,ShiftEntryDate,ShiftStartTime,ShiftEndTime,
TotHour,PositionID,Department,Rate,HospitalID)
VALUES ('Wednesday',CONVERT(VARCHAR(10),'10/04/2006',121),'NULL','1200','2100','NULL','1','2','100',1)
due to the date i am getting error so pls tell me where i am wrong and pls rectify my error.
thanx....
xzv
|
|
|
|
|
I don't understand why you are converting the date. I assume that ShiftDate is a DateTime or SmallDateTime column then you should just be able to put the date in a string and it will work.
My only suggestion is that, as a general rule, you should use the ISO format yyyy-mm-dd so that the format of the date is culture independent.
|
|
|
|
|
take the quotes off of the nulls
|
|
|
|
|
how to select the border of the picture box in run time?
plez help
|
|
|
|
|
hello everyone.
Do you have an easy way when resize my windows form, proportionally to resize all components(Picturebox, buttons,textboxes, graphics etc.)
Thanks.
|
|
|
|
|
Check out the Anchor, Fill and Dock properties of the controls...
Splitter controls can help as well.
Good luck...
|
|
|
|
|
it depends what you need. Anchor and docking can do alot, but the only way I could grow two groupboxes 50/50 in a form was by handling resize manually. Everything inside the groupboxes was handled by a combination of standard means but the 50/50 thing proved elusive.
|
|
|
|
|
Is there a way of casting a generic list to another one, best way to explain what I want is, imagine the following scenario
public class Customer : Person { ... }
public class Criminal : Person { ... } Now there's a dictionary object to provide a lookup table:
Dictionary<Type, List<Person>> lists; And I'd like this dictioanry to contain a list of Customers and Criminals so...
lists.Add(typeof(Customer), new List<Customer>());
lists.Add(typeof(Criminal), new List<Criminal>()); However this complains that there's no conversion between List<Customer> and List<Person>.
This code will be accessed later on, for arguments sake through a method like this:
public List<T> GetList<T>() where T : Person
{
return lists[typeof(T)];
}
Anybody have any ideas on how to accomplish this. The objects (Customer and Criminal) can be cast to Person and back again but it does not like casting the lists. Any ideas on "fooling" the compiler into doing what I want?
Sig cops got me...
|
|
|
|
|
I've found a work-around (not very nice but it works), declare Dictionary<Type, object> lists;
Sig cops got me...
|
|
|
|
|
You could use a Converter
<code>
List<Customer> customers = new Converter<Customer, Person>( CustomerToPerson )
private Person CustomerToPerson(Customer c)
{
return (Person)c; // More complicated I know, but you get the idea
}</code>
only two letters away from being an asset
|
|
|
|
|
I did think of something along those lines but doing that would result in potentially thousands of casts. (Maybe I'm being stupid though), but the way I'm doing it at the moment only has one cast and it's hidden in the internal implementation anyway so I'll go with that for the time being until I can think of a better way, or MS decide to fix the "problem".
Sig cops got me...
|
|
|
|
|
You cannot cast a List<customer> to List<person> because List<person> supports .Add(person), but you then you could add criminals to your customers list.
|
|
|
|
|
Yep, I agree, that's why it's complaining, but then again it won't let me add a List<Criminal> to the dictionary in the first place which would have solved these "problems".
I think that the only half-decent way around this is to use the dictionary to store object s. I just have to make sure that it never returns the wrong object to cast.
Sig cops got me...
|
|
|
|
|
Hello all, I am having a little trouble with a ListView. I am trying to update an item but it isn't doing what it should...
To explain: I have a list containing about 20 items. I can find the index location for the item I want to update. I am then removing the old item at the found index location, and then inserting the new item at the same point. It works, but with one problem...
It isn't inserting the new item at the correct index position. Instead it is putting it at the bottom of the list... And I can't work out why??
I am viewing the list in 'tile' view.
Can anybody help?
Thanks in advance,
Phil
"Rules are for the obedience of fools and the guidance of wise men"
|
|
|
|
|
Hello,
You tried already :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformslistviewlistviewitemcollectionclassinserttopic.asp
Creates a new item and inserts it into the collection at the specified index.
[C#] public ListViewItem Insert(int, string);
that doesn't work?
You have some code ?
|
|
|
|
|
Thanks for the reply...
I can insert the item. It is just not being inserted where I asked it to be...
Here is the code:
ListViewItem temp = new ListViewItem();<br />
temp = listView_main.FindItemWithText(item_text, true, 0);<br />
int location = temp.Index;<br />
<br />
ListViewItem lvItem = new ListViewItem(item_text, icon);<br />
lvItem.SubItems.Add("Name:" + name + "(" + aka + ")");<br />
lvItem.SubItems.Add("Data:" + data);<br />
lvItem.ToolTipText = item.ToString();<br />
lvItem.Group = listView_main.Groups[0];<br />
<br />
listView_main.Items.RemoveAt(location);<br />
<br />
listView_main.Items.Insert(location, lvItem);
Hope that helps...
Phil
"Rules are for the obedience of fools and the guidance of wise men"
|
|
|
|
|
namespace codepro
{
///
/// Zusammenfassung für Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.ListView TheList;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.Button button1;
///
/// Erforderliche Designervariable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Erforderlich für die Windows Form-Designerunterstützung
//
InitializeComponent();
//
// TODO: Fügen Sie den Konstruktorcode nach dem Aufruf von InitializeComponent hinzu
//
}
///
/// Die verwendeten Ressourcen bereinigen.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Vom Windows Form-Designer generierter Code
///
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
///
private void InitializeComponent()
{
System.Windows.Forms.ListViewItem listViewItem1 = new System.Windows.Forms.ListViewItem(new string[] {
"One",
"1.2.",
"1.3.",
"1.4."}, -1);
System.Windows.Forms.ListViewItem listViewItem2 = new System.Windows.Forms.ListViewItem(new string[] {
"Two",
"2.1.",
"2.2.",
"2.3."}, -1);
System.Windows.Forms.ListViewItem listViewItem3 = new System.Windows.Forms.ListViewItem(new string[] {
"Four",
"4.1.",
"4.2.",
"4.3."}, -1);
this.TheList = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// TheList
//
this.TheList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2});
this.TheList.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
listViewItem1,
listViewItem2,
listViewItem3});
this.TheList.Location = new System.Drawing.Point(24, 16);
this.TheList.Name = "TheList";
this.TheList.Size = new System.Drawing.Size(200, 232);
this.TheList.TabIndex = 0;
this.TheList.View = System.Windows.Forms.View.List;
this.TheList.SelectedIndexChanged += new System.EventHandler(this.TheList_SelectedIndexChanged);
//
// columnHeader1
//
this.columnHeader1.Text = ":: 1 ::";
//
// columnHeader2
//
this.columnHeader2.Text = ":: 2 ::";
//
// button1
//
this.button1.Location = new System.Drawing.Point(240, 80);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(48, 64);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.button1);
this.Controls.Add(this.TheList);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
///
/// Der Haupteinstiegspunkt für die Anwendung.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void TheList_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
private void button1_Click(object sender, System.EventArgs e)
{
System.Windows.Forms.ListViewItem listViewItemIns = new System.Windows.Forms.ListViewItem(new string[] {
"Three",
"3.1.",
"3.2.",
"3.3."}, -1);
TheList.Items.Insert(2,listViewItemIns);
Refresh();
}
}
}
The button1_Click inserts the Item "Three" at the correct place
So i doesn't see a mistake in you code
|
|
|
|
|
I am using a textbox which takes date of birth as input
I want to use regular expression validator for that textbox
The Date Format Should Be mm/dd/yyyy
and valid date
Can Enyone Hel me Out
|
|
|
|
|
|
You can use a Masked Textbox?
|
|
|
|
|
If you want a regex the following should work
\d{2}/\d{2}/\d{4}
Not very advanced, just checks for 2 digits followed by a slash and 2 more digits, then a slash then a group of four digits.
Sig cops got me...
|
|
|
|
|
You can use a pattern like "\d{2}/\d{2}/\d{4}" to validate only the format. You can rule out dates that clearly are invalid with a pattern like "(0[1-9]|[12]\d|3[01])/(0[1-9]|1[0-2])/(19|20)\d\d", but a pattern that would actually check if the date is valid would be extremely complex. Just imagine all the combinations to validate the correct number of days in the different months, then imagine leap years on top of that...
---
b { font-weight: normal; }
|
|
|
|
|
If the regex isn't an absolute requirement, look into DateTime.TryParse()
|
|
|
|
|
Hi all,
I want an image button (ie, fully owner drawn) where the image has some transparancy.
The button sits on a form which has a custom OnPaint which draws to the form surface, the button lies on top. So, the transparant parts of the button should show the image on the form underneath.
In the constructor of my image button class, I set the styles UserPaint, AllPaintingInWmPaint, and DoubleBuffer.
In my OnPaint override, I simply draw the button.
But it doesn't work, the background behind the button is not what I drew on the form. In fact, it seems to be the image for the standard button toolbar (in blue). No idea why.
Anyone got any pointers?
Thanks
Jon
|
|
|
|
|
The problem with Transparency and controls is that it's NOT transparent. A control cannot be made to be fully transparent. Why? Well, because when the controls parent container paints it's background, it paints around the controls it contains, leaving holes (regions) in the background where the constituent controls will show up. It's up to the controls to paint themselves into those holes. All the controls know is that they have a surface to paint on. That surface is NOT part of the parent container!
Setting a controls BackColor to Transparent tells the control to take on the background of the parent container. It does not make the control transparent! The control simulates this transparency by using the BackColor and BackgroundImage properties of it's parent container, so it blends in with the background of the parent! The control knows nothing of other child controls in any parent container, or any grandparent container.
This means that if you put, say, two 2 button controls on the form and overlap them so one button is partially obscuring the other and you make the top button transparent, you will NOT see the remaining part of the covered button through the top button! You will see the background of the parent container both buttons sit in!
Try this... Drop a Panel control on a form, then either set it's background to a bitmap image and make sure it streches to fill the entire panel, or set it's backcolor to any color. Then drop a Label control on the Panel and make it take up about 1/4th the size of the Panel. Change it's BackColor to anything, except Transparent. Then drop another Label control on the Panel and position it so that one corner covers a corner of the other Label. Change it's BackColor to Transparent and watch what happens.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|