|
Are you actually connecting to Informix here? If you are, I think you'll probably find that you are trying to use the SQL Server data classes to access them - hence the reason the connection doesn't open.
|
|
|
|
|
I put another code :
private void Form1_Load(object sender, EventArgs e)
{
try
{
con = new OdbcConnection();
con.ConnectionString = @"Dsn=***;Driver={SCO Vision ODBC};uid=***;Pwd=****";
con.Open();
con);
adap = new OdbcDataAdapter("SELECT TOP 100 informix.thisent.etb FROM informix.thisent", con);
Ds = new System.Data.DataSet();
adap.Fill(Ds, "ibr");
dataGridView1.DataSource = Ds.Tables[0];
}
catch (Exception ex)
{
MessageBox.Show("ERREUR\n" + ex.Message, "ERREUR", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
BUT I have an error :
error [42S22][SCO VISION][ODBC DRIVER][INFORMIX] column (top) not found in any table in the query .
|
|
|
|
|
That's because you are using illegal syntax in Informix. My Informix is a bit rusty, but I'm pretty sure you're meant to use SELECT FIRST 100 ... to get the data back. TOP is a SQL Server keyword.
|
|
|
|
|
It's good, I would give you a gift when you come in France
|
|
|
|
|
You must instantiate the connection and then open a database. Here is an example
OdbcConnection cnn = new OdbcConnection("DSN=DATABASE");
cnn.Open();
The parameter in this case would be the connection string. There are many different ways the connection string may be formed. It depends partially on which database type you are opening (SQL Server, MsAccess, Oracle, etc)
|
|
|
|
|
Hi, I want the Generate xls file in Window Service Location Generate Client Side, if anyone can help me , Thanks
|
|
|
|
|
Member 8414501 wrote: if anyone can help me Will do, as soon as you have a question.
As a side-note; a Windows-service is something that runs on the PC before the user logs on, does not show a UI and usually runs under other credentials than the current user.
Did you mean a "web service"?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
In my login form i have loaded role dropdown from database.
When user clicks on login button (while not selecting any role from dropdown.)
i have to retain same login page. but again roles dropdown is loading from database.
How can i avoid database hit another time in login page when validation fails in login page ?
Please help me.
kranthikumar2555@gmail.com
Kranthikumar
|
|
|
|
|
|
You have a valid SMS Gateway to send to, you have a valid SMS Gateway Domain id, and there is no reason for that Gateway to reject a message from the originating party based on their location or any other factor: correct ?
If your end-users have the Skype client, have you considered the Skype API's: [^].
« There is only one difference between a madman and me. The madman thinks he is sane. I know I am mad. » Salvador Dali
modified 23-Oct-14 13:18pm.
|
|
|
|
|
I found this class on a forum...
How do I use it - I can't seem to callthe Difference method in bold text?
I'm currently trying...
DateDiff dateDiff = new DateDiff();
dateDiff.Difference((DateTime)StartDate, (DateTime)EndDate); // Doesn't Work
Many thanks for any help.
public class DateDiff
{
private int _Years = 0;
private int _Months = 0;
private int _Weeks = 0;
private int _Days = 0;
private int _Hours = 0;
private int _Minutes = 0;
private int _Seconds = 0;
public int Years { get { return _Years; } }
public int Months { get { return _Months; } }
public int Weeks { get { return _Weeks; } }
public int Days { get { return _Days; } }
public int Hours { get { return _Hours; } }
public int Minutes { get { return _Minutes; } }
public int Seconds { get { return _Seconds; } }
public override string ToString()
{
return String.Format("{0} year{1}, {2} month{3}, {4} week{5}, {6} day{7}, {8} hour{9}, {10} minute{11}, {12} second{13}"
, Years, Years != 1 ? "s" : ""
, Months, Months != 1 ? "s" : ""
, Weeks, Weeks != 1 ? "s" : ""
, Days, Days != 1 ? "s" : ""
, Hours, Hours != 1 ? "s" : ""
, Minutes, Minutes != 1 ? "s" : ""
, Seconds, Seconds != 1 ? "s" : ""
);
}
static public DateDiff Difference(DateTime dt1, DateTime dt2)
{
if (dt1 > dt2)
{
DateTime dtTemp = dt1;
dt1 = dt2;
dt2 = dtTemp;
}
DateDiff dd = new DateDiff();
dd._Years = dt2.Year - dt1.Year;
if (dd._Years > 0)
{
if (dt2.Month < dt1.Month)
{
dd._Years--;
}
else if (dt2.Month == dt1.Month)
{
if (dt2.Day < dt1.Day)
{
dd._Years--;
}
else if (dt2.Day == dt1.Day)
{
if (dt2.Hour < dt1.Hour)
{
dd._Years--;
}
else if (dt2.Hour == dt1.Hour)
{
if (dt2.Minute < dt1.Minute)
{
dd._Years--;
}
else if (dt2.Minute == dt1.Minute)
{
if (dt2.Second < dt1.Second)
{
dd._Years--;
}
}
}
}
}
}
dd._Months = dt2.Month - dt1.Month;
if (dt2.Month < dt1.Month)
{
dd._Months = 12 - dt1.Month + dt2.Month;
}
if (dd._Months > 0)
{
if (dt2.Day < dt1.Day)
{
dd._Months--;
}
else if (dt2.Day == dt1.Day)
{
if (dt2.Hour < dt1.Hour)
{
dd._Months--;
}
else if (dt2.Hour == dt1.Hour)
{
if (dt2.Minute < dt1.Minute)
{
dd._Months--;
}
else if (dt2.Minute == dt1.Minute)
{
if (dt2.Second < dt1.Second)
{
dd._Months--;
}
}
}
}
}
dd._Days = dt2.Day - dt1.Day;
if (dt2.Day < dt1.Day)
{
dd._Days = DateTime.DaysInMonth(dt1.Year, dt1.Month) - dt1.Day + dt2.Day;
}
if (dd._Days > 0)
{
if (dt2.Hour < dt1.Hour)
{
dd._Days--;
}
else if (dt2.Hour == dt1.Hour)
{
if (dt2.Minute < dt1.Minute)
{
dd._Days--;
}
else if (dt2.Minute == dt1.Minute)
{
if (dt2.Second < dt1.Second)
{
dd._Days--;
}
}
}
}
dd._Weeks = dd._Days / 7;
dd._Days = dd._Days % 7;
dd._Hours = dt2.Hour - dt1.Hour;
if (dt2.Hour < dt1.Hour)
{
dd._Hours = 24 - dt1.Hour + dt2.Hour;
}
if (dd._Hours > 0)
{
if (dt2.Minute < dt1.Minute)
{
dd._Hours--;
}
else if (dt2.Minute == dt1.Minute)
{
if (dt2.Second < dt1.Second)
{
dd._Hours--;
}
}
}
dd._Minutes = dt2.Minute - dt1.Minute;
if (dt2.Minute < dt1.Minute)
{
dd._Minutes = 60 - dt1.Minute + dt2.Minute;
}
if (dd._Minutes > 0)
{
if (dt2.Second < dt1.Second)
{
dd._Minutes--;
}
}
dd._Seconds = dt2.Second - dt1.Second;
if (dt2.Second < dt1.Second)
{
dd._Seconds = 60 - dt1.Second + dt2.Second;
}
return dd;
}
}
|
|
|
|
|
Why not use the .NET DateTime Structure[^] which offers such features, and more? And. more importantly, it is fully documented and supported.
|
|
|
|
|
Try:
DateDiff diff = DateDiff.Difference(dt1, dt2);
But...You do realize there is a TimeSpan structure already in the .NET framework?
MSDN[^]
So you could just say:
TimeSpan diff = dt2 - dt1;
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Thanks for replying. I realize there is a TimeSpan but it's no use to me as it doesn't show Weeks or Years elapsed and I need them.
Your example worked (many thanks) - I hadn't noticed that the method was static...
|
|
|
|
|
|
Many thanks for the link - It doesn't quite go far enough for me though as I also need access to the hours and seconds (which the class I posted gives me - [I need to test it though]).
|
|
|
|
|
DateTime and TimeSpan give you everything you want, as I said in my earlier post. But you do have to read the documentation.
|
|
|
|
|
imho, the code you found is very poorly written, and to attempt to modify it is a waste of time.
CodeProject has a C# library for every possible DateTime calculation of exceptional quality by Jani Giannoudis, "Time Period Library:" [^].
« There is only one difference between a madman and me. The madman thinks he is sane. I know I am mad. » Salvador Dali
|
|
|
|
|
You might want to verify your requirements first before attempting something like this.
For example how many "days" exist between the following periods? How many "hours"?How many "days"? And does the answer change if the time zone does?
- July 7, 23:40 to July 8, 00:15
- Dec 31, 23:40 to Jan 1, 00:15
These are often business requirements and depends on what business needs are.
As another extreme example if one needs seven "business" days around December 25th then what impacts do holidays and weekends have on what the actual span is.
|
|
|
|
|
Hi,
I would like to ask what protocol is used for Teamviewr? and how can I make simple application similar to it?
Thanks,
Jassim
Technology News @ www.JassimRahma.com
|
|
|
|
|
You can find some details here[^], and I seriously doubt you could make a simple application like it. It's a very complicated piece of software (and it's certainly not written in C#).
|
|
|
|
|
Still not figured out how to use Google[^]?
|
|
|
|
|
Still not figured out how to use Google[^]?
Please read my question again..!
Technology News @ www.JassimRahma.com
|
|
|
|
|
|
The Protocol is not simple at all. If you want to do something similar take a look at VNC. If you want to connect clients through firewalls and routers search for hole punching or take a look at azure service bus.
|
|
|
|