|
Are you connecting to the server from your local machine ? Is this in ASP.NET ? Seems to me like you wrote code expecting it to run locally, but it runs on the server.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hi,
I am doing a program with c# and mysql database.
the task is actually taking 2 dates out from the mysql database and compare the 2 dates. if it is more than x days den the file will be deleted.
the following is the program that i have done but i am stuck at the logic that is compare the 2 days if more than x days delete the file.
after that i'll run in the schedule task so that it will run automatically at certain time.
here is my code.
string ConnectionString = "server=localhost;user id=name;password;persist security info=True;database=name of database;";<br />
using (MySqlConnection conn = new MySqlConnection(ConnectionString))<br />
{<br />
MySqlCommand cmd = new MySqlCommand();<br />
conn.Open();<br />
if (conn.State == ConnectionState.Open)<br />
{<br />
<br />
<br />
cmd.Connection = conn;<br />
cmd.CommandText = "select history ,lastclrhistorydate from table;";<br />
cmd.CommandType = CommandType.Text;<br />
MySqlDataReader reader;<br />
reader = cmd.ExecuteReader();<br />
if ((reader != null))<br />
{<br />
DataTable dt = new DataTable();<br />
dt.Load(reader);<br />
<br />
if (dt.Rows.Count == 1)<br />
{<br />
int history = int.Parse(dt.Columns[0].ToString());<br />
<br />
string lastclrhistory =dt.Columns[1].ToString();<br />
DateTime currentdate = DateTime.Now;<br />
<br />
<br />
if ((currentdate - lastclrhistory) == history)<br />
{<br />
}<br />
|
|
|
|
|
You can't compare two objects of differnt types. You need to grab the date, as a date, or use DateTime.TryParse to convert it.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
but in the database it is already in date
|
|
|
|
|
That doesn't matter because you've now converted it to a String, just because the string contains a DT format doesn't mean it will be interpreted that way, you must tell it that its a DateTime.
He who makes a beast out of himself gets rid of the pain of being a man
|
|
|
|
|
Did you come from VB, or do you just not know much about programming yet ? you should buy a book on C# and work through it, you're obviously missing some key concepts.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hi,
I am doing a program with c# and mysql database.
the task is actually taking 2 dates out from the mysql database and compare the 2 dates. if it is more than x days den the file will be deleted.
the following is the program that i have done but i am stuck at the logic that is compare the 2 days if more than x days delete the file.
after that i'll run in the schedule task so that it will run automatically at certain time.
here is my code.
string ConnectionString = "server=localhost;user id=name;password;persist security info=True;database=name of database;";
using (MySqlConnection conn = new MySqlConnection(ConnectionString))
{
MySqlCommand cmd = new MySqlCommand();
conn.Open();
if (conn.State == ConnectionState.Open)
{
cmd.Connection = conn;
cmd.CommandText = "select history ,lastclrhistorydate from table;";
cmd.CommandType = CommandType.Text;
MySqlDataReader reader;
reader = cmd.ExecuteReader();
if ((reader != null))
{
DataTable dt = new DataTable();
dt.Load(reader);
if (dt.Rows.Count == 1)
{
int history = int.Parse(dt.Columns[0].ToString());
string lastclrhistory =dt.Columns[1].ToString();
DateTime currentdate = DateTime.Now;
if ((currentdate - lastclrhistory) == history)
{
//(File.delete(file)
}
|
|
|
|
|
Hi,
in my Folder of the app there are
tow folder in the bin Folders :
Debug and Release
tha strange thing is that :
under the Solution properties it is set to :
Configuration : Active(Release)
and the OutPut Path is bin\Release\
BUT it always complie it to the Bedug Folder
What am i'm doing wrong?
THANKS
Have Fun
Never forget it
|
|
|
|
|
Have you checked the output path settings in the project's properties (build tab)?
Standards are great! Everybody should have one!
|
|
|
|
|
yes as i wrote "OutPut Path is bin\Release\"
THANK
Have Fun
Never forget it
|
|
|
|
|
Check the project properties and ensure that the output of the project is going to the correct folder for the correct build type.
|
|
|
|
|
yes as i wrote "OutPut Path is bin\Release\"
THANK
Have Fun
Never forget it
|
|
|
|
|
Right click on your solution.
Select properties.
Go to Configuration Properties -> Configuration.
Check what the Project Contents Grid shows.
|
|
|
|
|
i am using this code
MySqlConnection n = new MySqlConnection();
Type type= n.GetType();
System.Reflection.MethodInfo method = type.GetMethod("Add_Clone_Template");
which has four string parameters
Now i dont have the parameters as four strings i have a string
"fun1(fun2()),func4(),func3(fun4(),func1("value")";
fun1,fun2,fun3,fun4 all return a string
how can i pass this
modified on Thursday, March 13, 2008 4:05 AM
|
|
|
|
|
Waheed Ur Rehman wrote: Now i dont have the parameters as four strings i have a string
"fun1(fun2()),func4(),func3(fun4(),func1("value")";
fun1,fun2,fun3,fun4 all return a string
So where are these functions supposed to run on?
|
|
|
|
|
When a mode dialog show in Vista, surrounding screen of dialog is become dim.
How to do this effect with C#?
My OS is XP-sp2 and Vista an among thoseses.
has anybody did this effect sample here?
I want to study.Thanks.
|
|
|
|
|
Your best bet is to do a full screen borderless dialog, and make it semi transparent. Then put your form above it.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Why did you vote Christian's answer down? He's told you exactly how to do it.
|
|
|
|
|
i want to change the regional settings -> inputlocale programtically, how can i do that one using c#?
hemanth
|
|
|
|
|
You can use CultureInfo for changing Regional Setting.
Thanks
Anubhava Dimri
anubhava.prodata@gmail.com
9250168195
|
|
|
|
|
but i want to change it on o/s level, not for the particular application or for the form...
thanks for u r reply.
hemanth
modified on Thursday, March 13, 2008 2:47 AM
|
|
|
|
|
U can change Runtime System Information by System Culture Informatin /Shell Command
using Shell32;
Shell objshell = new Shell();
objshell.ControlPanelItem("intl.cpl");
ANUBHAVA Dimri
anubhava.prodata@gmail.com
925168195
|
|
|
|
|
Thank u for ur information, but it will open the regional settings, my intention is to with out user interaction i have to change the input locale value.
hemanth
|
|
|
|
|
I Have a new style of Changing Regional Setting of System at Runtime
You Can Change Registry Value of System at Runtime
Just Like for Date
Change value of Date
My_Computer/HKEY_USERS/S-1-5-21-682003330-162531612-725345543-1003/Control Panal/Internation/
Set the value of sShortDate "dd/MM/yyyy"
Anubhava Dimri
anubhava.prodata@gmail.com
9250168195
|
|
|
|
|
I u not want to use this method .These two function are getting and Setting for System Information.
Public Const LOCALE_SSHORTDATE = &H1F
Public Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long
Public Declare Function SetLocaleInfo Lib "kernel32" Alias "SetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String) As Boolean
Public Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long
Anubhava Dimri
|
|
|
|