|
|
Not a valid month error (ORA-1843)
More fun with ODP.NET - Tried different format string none worked!! wasted couple of hours!!
My table column is defined as:
CreateDate timestamp default sysdate NOT NULL
This is first thing I tried (most intuitive right?) This don't work ...
<br />
oParam.DbType = DbType.DateTime;<br />
oParam.Value = DateTime.Now;<br />
Error message in this case was: "ORA-01858: a non-numeric character was found where a numeric was expected"} System.Exception {Oracle.DataAccess.Client.OracleException}
So I tried many things... no luck
<br />
oParam.Value = DateTime.Now.ToString("dd-MMM-yy");
oParam.Value = DateTime.Now.ToString("dd-MM-yy");<br />
oParam.Value = DateTime.Now.ToString("MM-dd-yy");<br />
oParam.Value = DateTime.Now.ToString("MM/dd/yy");<br />
oParam.Value = DateTime.Now.ToString("dd/MM/yy");<br />
Also tried different combinations using MMM, NO LUCK!!
I then Checked db date format via:
select sysdate from dual;
SYSDATE
16-APR-09
1 row selected.
Last trick (Works but UGLY) - use to_date function in my sql statement + string concatenation instead of parameter!!!
select to_date('16-4-09', 'dd-mm-yy') today from dual
Code:
if (oContext.DefaultDBProvider == DBUtil.DataProvider.OracleODAC || oContext.DefaultDBProvider == DBUtil.DataProvider.OracleProvider)<br/>
{
strSQL_insert = strSQL_insert.Replace(ORACLE_CREATEDATE, "to_date('" + DateTime.Now.ToString("dd-MM-yy") + "', 'dd-MM-yy')");
}
else
{
oParam = oCmd.CreateParameter();
oParam.ParameterName = DBUtil.FixParameterNameForOracle(oContext.DefaultDBProvider, "@CreateDate");
oParam.Direction = ParameterDirection.Input;
oParam.DbType = DbType.DateTime;
oCmd.Parameters.Add(oParam);
}
Any suggestion? I've isolated the one offending parameter but need the right "format" and ora messages is not helpful at all.
REF:
http://forums.oracle.com/forums/thre...hreadID=631236
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
dev
modified on Thursday, April 16, 2009 9:14 AM
|
|
|
|
|
try "yyyy-MM-dd" (and read ISO 8601 standard).
|
|
|
|
|
yeah tried that too not good mate
dev
|
|
|
|
|
btw - using MMM means month is non-numeric.
<br />
CASE 1: dd-MMM-yy ---> 16-Apr-09<br />
CASE 2: dd-MMM-yy hh:mm:ss.ffff tt ---> 16-Apr-09 08:50:46.6093 PM<br />
In both cases, you'd end up with:
<br />
ORA-01858: a non-numeric character was found where a numeric was expected"} System.Exception {Oracle.DataAccess.Client.OracleException}<br />
dev
|
|
|
|
|
devvvy wrote: using MMM means month is non-numeric
I am familiar with DateTime type, and all databases I used so far accept "yyyy-MM-dd";
Oracle is not amongst them.
|
|
|
|
|
yes my code works for M$SQL + MySQL too, just seems like it's not friendly with Oracle...
dying.. ekkkKK
dev
|
|
|
|
|
Problem resolved, thanks to Alex Oracle Consultant!
http://forums.oracle.com/forums/thread.jspa?messageID=3407801#3407801
dev
|
|
|
|
|
good for you!
I understood:
1. to_date() is unavoidable with Oracle?
2. parameter order is relevant unless some flag set true (where?)
|
|
|
|
|
oh no
Just do this:
oParam = oCmd.CreateParameter();
oParam.ParameterName = ":CreateDate";
oParam.Direction = ParameterDirection.Input;
oParam.DbType = DbType.DateTime;
oParam.Value = DateTime.Now;
oCmd.Parameters.Add(oParam);
I had problem I had only because I didn't:
((Oracle.DataAccess.Client.OracleCommand)oCmd).BindByName = true;
As usual Oracle error message was very misleading.
http://forums.oracle.com/forums/thread.jspa?messageID=3407801#3407801[^]
dev
|
|
|
|
|
Thanks for the info. I may come handy some day...
|
|
|
|
|
no problem mate cheers
dev
|
|
|
|
|
i am having so much fun with ODP.NET/C#
CREATE TABLE GENERICPROPERTY (
...
CreatedBy numeric(19,0) DEFAULT -1 NOT NULL,
...
)
Also tried numeric(18,0) for .NET Int64 or long type. No luck!
Keep getting error: {"ORA-01722: invalid number"} System.Exception {Oracle.DataAccess.Client.OracleException}"
This is the code - I've isolated it down to this parameter by trial and error (commenting out param one-by-one)
oParam = oCmd.CreateParameter();
oParam.ParameterName = DBUtil.FixParameterNameForOracle(oContext.DefaultDBProvider, "@CreatedBy");
oParam.DbType = DbType.Int64;
oParam.Direction = ParameterDirection.Input;
oParam.Value = oContext.LogonUserId; << This is .NET Int64/long
oCmd.Parameters.Add(oParam);
Any suggestion? Thanks
REF:
http://www.dba-oracle.com/sf_ora_01722_invalid_number.htm
dev
|
|
|
|
|
Problem resolved, thanks to Alex Oracle Consultant!
http://forums.oracle.com/forums/thread.jspa?messageID=3407801#3407801
dev
|
|
|
|
|
hi
I hv created a web form similar to the web form in my company site
now i want to link my web form to company web form.
As my web form debug ,data comes in my web form
and then it displayed in the company web form and get saved
in the company database.
PLZZZZZZ HELP ME n tell me the code plzzzzzzzz
|
|
|
|
|
I have a datagridview with 1200+ names in it. My users want to type in a few letters (in a separate textbox) of a name and jump to the first name starting with these letters. I have a special column named shortname for this purpose.
I've made a dataview with the filter option, and that works but only the names with these letters are shown. What my users want is the complete list (sorted by short name), and the first occurance of the search letters selected.
can anybody point me in the right direction ?
I'm using C#2008
Thanks in advance,
Rob
|
|
|
|
|
What about looping all the datagridview rows with a foreach, checking the desired column for a partial match, if found then get the index of the found row and break the loop. then set the FirstDisplayScrollingRowIndex of the dataGridView to be the index you obtained from the loop
Example?...
int index = -1;
string searchText = textBox1.Text;
foreach(DataGridViewRow row in dataGridView1.Rows)
{
if(row.Cells["shortname"].Value.ToString().StartsWith(searchText))
{
index = row.Index;
break;
}
}
if(index >= 0)
dataGridView1.FirstDisplayScrollingRowIndex = index;
...This code should be put in a TextChanged event handler for the textbox
Actually, in regards to the example code, you can just assign the FirstDisplayScrollingRowIndex propoerty inside the loops if statement and remove the need for the 'index' variable.
Of course, there may be a built in function i dont know about, if you have found a better solution already then please post it
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I was indeed looking for a more elegant solution, but as the data is already on the users computer a bit of number crunching should not take too long, so if no further ideas come up I will use your solution.
Thanks for your time.
Rob
|
|
|
|
|
Hi everyone,
I have a Windows service that I made on my PC here which has Win XP pro on it and it creates some event logs. It runs fine here but now when I'm trying to deploy it on Staging environment where we have Windows Server 2003, it just doesn't run cause it need the administrative rights for it. Can any one tell me how to tackle this situation. Is there a way to impersonate the Windows Service or anything else?
Any help would be greatly appreciated.
Regards,
|
|
|
|
|
Open the configuration screen, and go to the administrative tools. From there, open the "Services" MSC. Find your service in the list, rightclick it and select "Properties". The second tabpage (called Log On) lets you specify the user-account under which the service should run.
Good luck
I are troll
|
|
|
|
|
ahh!! Thanks man, that was beautiful.
|
|
|
|
|
You're welcome, and thanks for the kind words
I are troll
|
|
|
|
|
Hi, Everybody.
I'm a newbie in C# and I need all your suggestion, advice or script about below script.
I have a class function called FormAction() as below that will keep all the form called. When I have more forms, then I need to do same calling method.
private void FormAction(FormName)
{
switch(FormName)
{
case "frmGUI1":
frmGUI1 lfrm1 = (frmGUI1)Application.OpenForms(FormName);
lfrm1.Show();
break;
case "frmGUI2":
frmGUI2 lfrm2 = (frmGUI2)Application.OpenForms(FormName);
lfrm2.Show();
break;
case "frmGUI3":
frmGUI3 lfrm3 = (frmGUI3)Application.OpenForms(FormName);
lfrm3.Show();
break;
}
}
Can I just code in little line to perform called form? If can, can you give me examples or how to code it.
Thank for your help.
RoalearK
|
|
|
|
|
frmGUI1, frmGUI2 and frmGUI3 all derive from Form. Instead of the switch statement, cast Application.OpenForms(FormName) to a Form, and then call the Show method. So it would look like this:
private void FormAction(string FormName)
{
Form frm = Application.OpenForms(FormName) as Form;
if(frm != null)
frm.Show();
}
|
|
|
|
|
Thank buddy, But I still got some question on that.
How about I need to use that particular form function? For example below, frmGUI1, I need to call save function and frmGUI2, I need to call on Delete function.
If I use to that code cast to a Form frm = Application.OpenForms(FormName) as Form, am I can't to use particular form function?
private void FormAction(string FormName)
{
switch (FormName)
{
case "frmGUI1":
frmGUI1 lFrmGUI1 = (frmGUI1)Application.OpenForms(FormName);
lFrmGUI1.Save();
break;
case "frmGUI2":
frmGUI2 lFrmGUI2 = (frmGUI2)Application.OpenForms(FormName);
lFrmGUI2.Delete();
break;
}
}
Anyway, thank for your help.
RoalearK
|
|
|
|