|
Because you're executing a non-query[^]. As the documentation states;
Executes a Transact-SQL statement against the connection and returns the number of rows affected.
Your query affected 1 row, and that's what the function returns. Use a DataReader te read your row
I are troll
|
|
|
|
|
but i want to insert record into table .
|
|
|
|
|
Aw, I thought you wanted to insert your rows into a DataTable object. I should learn to read decently before answering a post.
In that case the ExecuteNonQuery is correct, my apologies. That would return "1" if it added a record. You might want to use parameters in your Insert-statement, that would also prevent some problems with SQL Injection and quoted strings. Take a look at OleDbParameter
I are troll
|
|
|
|
|
Can someone teach me how to compile a project like "Sandcastle File Help Builder" with makefile?
I'm a new user for Visual C# and I've just used a normal function to create .exe till now.
Regards,
Christian
|
|
|
|
|
Makefiles are not required to compile a C# app. Don't you have Visual Studio installed?
|
|
|
|
|
Yes. I use Visual Studio 2005. Maybe you can also see the Sandcastle-Source-Code which also can be downloaded here by codeproject.This source code has makefile in each c# project
|
|
|
|
|
|
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,
|
|
|
|