|
If you're going to insert the dates into a database, you're better off keeping them as DateTime s, otherwise you will run into problems with internationalization. If you really want to insert them as strings, I suggest you insert them as yyyy-MM-dd .
Cheers,
Vıkram.
After all is said and done, much is said and little is done.
|
|
|
|
|
It's better send them as DateTime and convert the parameter in your query .
something like following code
// In C#
string dateTime = "12.12.2007";
SqlCommand cmd=new SqlCommand();
cmd.Parameter.AddWithValue("@currentDateTime", dateTime);
.
.
.
// In StoredProcedure or your query string
DECLARE @dateTime DateTime;
// Using Convert function to convert string data type to datetime data type
SET @dateTime = Convert(datetime,@dateTime);
DMASTER
|
|
|
|
|
Assume you know the date string format, example in format MM/DD/YYYY, or DD/MM/YYYY, or any format, you can write a common function to pass this string in, and output a value in date format.
You can get the function here --> http://www.oin1.com/Technical/CSharp/FormatDateString.htm[^]
Eliz.K
|
|
|
|
|
Hey guys,
I've installed my solution on a diffrent than development computer, everything works fine. However, the setup (Setup & Deployment project in VS) delivers a couple of additional files used in the app as content (backgrounds & stuff). However when you stop the application and change one of these files and then start the application again, MSI comes in to 'restore' the setup and then start the application
One of these files is an MDF (SQL database) file which is being attached during setup. Ofcourse this file changes and setup is restoring this file also... You can imagine that the app won't startup anymore.
How can I prevent the Microsoft Installer from restoring files after setup??
Thnx! Eduard
|
|
|
|
|
Hi, i need some help in figuring this out. i have a class as shown below:
public interface IDrawable<br />
{<br />
void Draw( Graphics g );<br />
int CountNo(ArrayList al);<br />
}<br />
<br />
public class Ellipse : IDrawable<br />
{<br />
public Color c = Color.Black;<br />
public Point l = new Point(0, 0);<br />
public Size s = new Size(0, 0);<br />
public int stroke = 0;<br />
<br />
public Ellipse( Color c, Point l, Size s, int stroke )<br />
{<br />
this.c = c;<br />
this.l = l;<br />
this.s = s;<br />
this.stroke = stroke;<br />
}<br />
<br />
public void Draw( Graphics g )<br />
{<br />
g.DrawEllipse( new Pen( c, stroke ), l.X ,l.Y, s.Width,s.Height );<br />
}
in the form:
<br />
private ArrayList alDrawingObjects = new ArrayList();<br />
.......<br />
alDrawingObjects.Add( new Rect( Color.Black, new Point(pt.X, pt.Y), new Size(50, 50), 5 ) );<br />
alDrawingObjects.Add( new Rect( Color.Black, new Point(pt.X, pt.Y), new Size(50, 50), 5 ) );<br />
.......<br />
private void form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
{<br />
Graphics objGraphics ; <br />
objGraphics = e.Graphics;<br />
foreach ( IDrawable d in alDrawingObjects )<br />
{<br />
d.Draw( objGraphics );<br />
}<br />
objGraphics.Dispose();<br />
}
i need to be able to select with a mouseclick on any of the shape drawn. I thought of using Contain method but i don't know how to implement it. i know that i need to search through the array list and test if the mouseclick point or position is in the drawn shape. may i know how to implement this?
Thank u in advance.
|
|
|
|
|
cyn8 wrote: Graphics objGraphics ;
//You can't modify e.Graphics directly.
objGraphics = e.Graphics;
Bizarre. This is totally superfluous, AFAIK.
What you need to do is, in your mouse down event, iterate over the objects again, and check if the mouse is inside any of them.
Obviously, for an ellipse, you need to read up on the maths to find out if a point is inside an ellipse. One cheats way of doing it, is to create a new bitmap, draw the objects onto it in white, and check if your mousedown point is white or black as you draw each one. This is very inefficient, really should only be used where you can't work it out mathematically ( for example if you had a completely irregular shape )
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
<quote>What you need to do is, in your mouse down event, iterate over the objects again,...
can you explain further?
The problem is that for all the shape drawn before, i can't seem to save the area which they contained. if i mouseclick on the form, how can i check that the mouse click in within the area of the previously drawn shape. Please help, i've been cracking my head for hours.
Thanks
|
|
|
|
|
hi all,
pls somebody help me to load two combobox side by side on clicking a button(single click).i will attach my code.my code is building but i get the output with only one loaded combobox.another one remains empty
MY CODE:
DataTable table = new DataTable();
table.Columns.Add("SS");
DataRow row;
for (int i = 0; i < 10; i++)
{
row = table.NewRow();
row["SS"] = i + 1;
table.Rows.Add(row);
}
comboBox1.DataSource = table;
comboBox1.DisplayMember = "SS";
DataTable s = new DataTable();
s=table.Clone();
table.Columns.Add("SS1");
DataRow row1;
for (int j = 0; j < 10; j++)
{
row1 = table.NewRow();
row1["SS1"] = j + 1;
table.Rows.Add(row1);
}
comboBox2.DataSource = table;
comboBox2.DisplayMember = "SS1";
thank you,
saravana.
|
|
|
|
|
sowmyasaravanakumar wrote: another one remains empty
No. Just scroll down the comboBox2. You will see the new row that you just added..
Because of this line table.NewRow(); , new row will be appended to table1. So, first 10 rows of column "SS1" of table1 will be blank.
|
|
|
|
|
If you don't want to append new rows to table1 and you just want add one more column called SS1 and add the value then you may try the code below..
<br />
DataTable table = new DataTable();<br />
<br />
table.Columns.Add("SS");<br />
<br />
DataRow row;<br />
<br />
for (int i = 0; i < 10; i++)<br />
{<br />
row = table.NewRow();<br />
row["SS"] = i + 1;<br />
<br />
table.Rows.Add(row);<br />
}<br />
comboBox1.DataSource = table;<br />
comboBox1.DisplayMember = "SS";<br />
<br />
DataTable s = new DataTable();<br />
s = table.Clone();<br />
<br />
table.Columns.Add("SS1");<br />
int j = new int();<br />
foreach (DataRow dr in table.Rows)<br />
{<br />
dr["SS1"] = j++;<br />
}<br />
<br />
comboBox2.DataSource = table;<br />
comboBox2.DisplayMember = "SS1";
Hope it would help..
|
|
|
|
|
Hi all,
I'm trying to manipulate menuitems of a MdiParent from MdiChild, here's the code that i have
frmMain <- the MdiParent Form
private void Main_Load(object sender, System.EventArgs e)
{
frmsignon fs = new frmsignon();
fs.MdiParent = this;
fs.Show();
}
i'm trying the below code from my MdiChild form to manipulate the menus on my MdiParent form
private void frmSignOn_Load(object sender, System.EventArgs e)
{
frmMain fM = new frmMain();
fM.menuItem1.Enabled = false;
}
this code has no build errors, but it has no effect upon run time, the menuItem1 of my MdiParent form is still ENABLED.
What seems to be missing? Please help me make this work. Thanks in advance
-::maximus::-
|
|
|
|
|
use this.Parent
Form2 fr2 = (Form2)this.Parent;
and make menuItem1 public
but better approach is to make function in MDI parent to enable and disable menu item and call function in child using fr2.
|
|
|
|
|
Thanks ashuka
you mean changing the
frmMain fM = new frmMain();
to
Form2 fr2 = (Form2)this.Parent; ?
menuItem1 is already public.
-::maximus::-
|
|
|
|
|
yeah dear
Ashu
Ashish Kasama
|
|
|
|
|
Hmmm...
Im getting this error:
An unhandled exception of type 'System.InvalidCastException' occurred
Additional information: Specified cast is not valid.
my code on the MDIChild form looks like this now
private void frmSignOn_Load(object sender, System.EventArgs e)
{
frmMain fM = (frmMain)this.Parent;
fM.menuItem1.Enabled = false;
}
-::maximus::-
|
|
|
|
|
where you launch it
frmSignOn frm = new frmSignOn();
frm. MdiParent = this;
frm.Show();
and at the time of
private void frmSignOn_Load(object sender, System.EventArgs e)
{
frmMain fM = (frmMain)this.MdiParent;
fM.menuItem1.Enabled = false;
}
|
|
|
|
|
Thanks much! it really worked!
got what went wrong
private void frmSignOn_Load(object sender, System.EventArgs e)
{
frmMain fM = (frmMain)this.Parent;
frmMain fM = (frmMain)this.MdiParent;
fM.menuItem1.Enabled = false;
}
Thanks Ashu
Regards
-::maximus::-
|
|
|
|
|
you are welcome
|
|
|
|
|
hello ,
i want to export data from datagrid to excel sheet iam getting one error,
error:
Control 'DataGrid1__ctl3__ctl0' of type 'DataGridLinkButton' must be placed inside a form tag with runat=server.
iam getting error at this line
DataGrid1.RenderControl(htmlWrite);
please give me any advice
srinivas
|
|
|
|
|
Hi,
Hope this code help
private void button1_Click(object sender, System.EventArgs e)
{
SaveFileDialog SD= new SaveFileDialog();
SD.Filter = "csv|*.csv|Comma Seperated Files|*.csv|All Files|*.*";
SD.InitialDirectory = @"C:\";
if (SD.ShowDialog() == DialogResult.OK)
{
using (System.IO.StreamWriter writer = new System.IO.StreamWriter(SD.FileName))
{
int Colcnt = dsResults.Tables["tbl_Master_Pol_Lst"].Columns.Count;
int Rowcnt = dsResults.Tables ["tbl_Master_Pol_Lst"].Rows.Count;
for(int x=0;x<=(Colcnt-1);x++)
{
writer.Write(dsResults.Tables["tbl_Master_Pol_Lst"].Columns[x].ColumnName.Trim()+ ",");
}
writer.WriteLine();
for(int x=0;x<=(Rowcnt-1);x++)
{
for(int y=0;y<=(Colcnt-1);y++)
{
if (y == 2)
{
writer.Write("'" + dsResults.Tables["tbl_Master_Pol_Lst"].Rows[x].ItemArray.GetValue(y)+ ",");
}
else
{
String varData = Convert.ToString(dsResults.Tables["tbl_Master_Pol_Lst"].Rows[x].ItemArray.GetValue(y));
writer.Write(varData.Replace(","," ")+ ",");
}
}
writer.WriteLine();
}
writer.Flush();
MessageBox.Show(SD.FileName + " successfully created");
}
}
-::maximus::-
|
|
|
|
|
Thankyou zenithmaximus,
iam getting at savedialoguebox(SD)
iam using datagrid and also iam using paging for datagrid.
srinivas
|
|
|
|
|
Thankyou zenithmaximus,
iam getting at savedialoguebox(SD) <- you mean getting confused?
iam using datagrid and also iam using paging for datagrid.
the save dialogue statements is where you specify the path of where you're saving the data from your datagrid to a CSV file. The code applies to a scenario where you're saving your exported data from datagrid to a CSV(excel like) file, from clicking a botton.
-::maximus::-
|
|
|
|
|
iam getting error near save dialogue box C:\Inetpub\wwwroot\UserManagement\userdetails1.aspx.cs(170): The type or namespace name 'SaveFileDialog' could not be found (are you missing a using directive or an assembly reference?)
srinivas
|
|
|
|
|
Hi All,
I am new to C#. I have created a Windows Application and included a User Control in it. Now i want to use the User Control in my Form at Design Time. What is the procedure?
Thanks in advance.
|
|
|
|
|
Hello,
After you compiled it, you should see the UserControls in the Toolbox but not in the Standard Forms Controls.
There is a seperate region for your controls.
All the best,
Martin
|
|
|
|