|
Thanks for the reply.
I'm off to try it, probably take me a week though
|
|
|
|
|
Hi All,
How can I use a Stored Procedure (Oracle) in C#.
can I do this, or only SQL Server?
Regards,
Kolia
Kolia
|
|
|
|
|
I don't believe that I have heard of Oracle putting this in yet. Sql Server 2005 (Yukon) has this feature. The older versions do not.
Steve Maier, MCSD MCAD
|
|
|
|
|
kolia wrote:
How can I use a Stored Procedure (Oracle) in C#.
The same way you use them in Oracle, actually, and it's supported both by the .NET 1.0 beta ADO.NET driver for Oracle, as well as the one released into .NET 1.1 and included in all future versions of .NET.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Ah... must have read that too fast. I was thinking that it was creating stored procedures that are written in C#. That and its on my mind since I am using Yukon at work now.
Steve Maier, MCSD MCAD
|
|
|
|
|
You use stored procs pretty much the same way as you do with SQL Server, just that the named parameters are identified a little differently (common with different RDBMS's). From the .NET Framework SDK documentation for the OracleCommand.CommandType property:When the CommandType property is set to StoredProcedure, you should set the CommandText property to the full Oracle call syntax. The command then executes this stored procedure when you call one of the Execute methods (for example, ExecuteReader or ExecuteNonQuery).
The Connection, CommandType and CommandText properties cannot be set if the current connection is performing an execute or fetch operation.
The .NET Framework Data Provider for Oracle does not support the question mark (?) placeholder for passing parameters to an SQL statement called by an OracleCommand of CommandType.Text. In this case, named parameters must be used. For example:
SELECT * FROM Customers WHERE CustomerID = :pCustomerID
When using named parameters in an SQL statement or stored procedure, you must precede the parameter name with a colon ( . However, when referring to a named parameter elsewhere in your code (for example, when calling Add), do not precede the named parameter with a colon ( . The .NET Framework Data Provider for Oracle supplies the colon automatically. The same should also be true if you use an Oracle connection string using the System.Data.OleDb namespace classes. To note, the Oracle ADO.NET driver is provided in .NET 1.1 but was only a beta release for .NET 1.0 and, IIRC, is not officially supported (but works). You can use System.Data.OleDb classes for compatibility if you feel you must, but you would be wise to use .NET 1.1 anyway, as many, many performance enhancements and bug fixes were made to the codebase.
So, as an example:
OracleConnection conn = new OracleConnection("...");
OracleCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "myproc(:param1, :param2)";
cmd.Parameters.Add("param1", OracleType.Int32).Value = 1;
cmd.Parameters.Add("param2", OracleType.Char, 40).Value = "CodeProject");
using (conn)
{
conn.Open();
cmd.ExecuteNonQuery();
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I created a datagrid which is populated from an sql query. That works fine, but I also want to capture the datagrid recordcount. Is there an easy way to do this?
|
|
|
|
|
You can either get the count from the datasource that you are binding or you can get the count from the datagrid.items.count after binding the datagrid to the datasource
|
|
|
|
|
hi,
The best way to count no of records in that datagrid is using it's datasource only.
DataTable dt= Datagrid.DataSource as DataTable;
if(dt!=null)
{
int rce_count=dt.Rows.Count;
}
Otherwise you can adopt the way which is explained by other answer thread.;)
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
hi all..
i developing a program that populate a list of items to a listview control and update the list every 2 seconds..the problem is that when i repopulate the items to the listview the horizontal scroll bar return to the top of the listview ...i don't like this to happen...i want the scroll bar to remain at the same position before the listview updated...how can i do this??
thx for your time
|
|
|
|
|
Check into the .TopItem poperty and the .EnsureVisible() method. I think you'll find everything you need in those two members of th eListView .
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
I was wondering who is using what for zip libraries.
Turns out java.util.zip is a royal piece of junk and doesn't work with Japanese fonts.
Thanks,
Elena
|
|
|
|
|
I found this one easy to use, and reliable:
CSharpZip[^]
Gary
|
|
|
|
|
I am not sure if it supports Japanese fonts, but I agree with Gary, the one from icsharpcode.com is definately a good and easy one to work with.
Steve Maier, MCSD MCAD
|
|
|
|
|
Like Steve, I also agree with Gary. Besides, the java.util.zip.* class in vjslib.dll also has a bug where, IIRC, a ZIP created with it can't be unzipped by "standard" ZIP libraries and applications.
#ziplib (the link Gary gave you) is commonly used by many projects.
I wanted to add, too, that the .NET Framework 2.0 will include ZIP classes (and support for derivative compression streams) in the BCL (base class library), along with many other great features.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hey Elena,
I recently used SharpZipLib and so far it hasn't given me any problems.
Here is the URL:
http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx
I hope it helps.
Cheers,
Suthan
|
|
|
|
|
|
I was previously told by one of the "guru's" of this site that this was not a c# issue. That is not correct because C# is the only language that supports Web Page Comments.
When I use the "Build Comment Web Pages" on the Tools MEnu of VS.NET 2003, the following type of HTML comment is generated at the top of every HTM file
""
I have recently installed Service Pack 2 of Windows XP. Now when the above comment is detetected by IE6, the Internet Zone is considered to be "Restricted" instead of Local Machine. HOW CAN I GET AROUND THIS? Correcting the problem from the XP side is complicated and, as yet, I don't understand it.
Thanks for your help,
Gary Hyslop
|
|
|
|
|
Gary Hyslop at home wrote:
I was previously told by one of the "guru's" of this site that this was not a c# issue. That is not correct because C# is the only language that supports Web Page Comments.
Actually, he was correct. This issue has nothing to do with C#, but everything to do with the security settings in Internet Explorer. I haven't installed SP2 yet, so I can't give you an exact answer. But, the first thing to do is double check the Security settings in IE and try relaxing the security level a bit. If it says High, try lowering it to Medium and see what happens.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Actually, that is not a C# feature at all. The Microsoft Visual C# compiler supports generating document comments from the compiler. The comment XML grammar (schema) is not specific to C# at all and can be constructed manually. The VB.NET compiler in "Whidbey" (.NET Framework 2.0) will also be able to generate comments.
The tool in VS.NET to build a web site simply transforms the XML file that is generated for each assembly in your solution, just as NDoc[^] - one of many successful projects I've worked on - and other commercial applications do.
As Dave said, your problem is with Internet Explorer security settings and would not matter one bit if the web site you were viewing was generated from static HTML pages, PHP, ASP, ASP.NET, ol' CGI or anything else.
If you don't understand something, you ask in the right forum. This cannot be corrected on the server side, otherwise that would render security moot. It has to be solved from the client. Like many, many other sites on the web, if there are security settings keeping viewers from displaying the site the way you intend, then you have a support page instructing what they should do and hope they will do it (some may not because they don't understand - which means your directions are clear enough, typically - or because they choose not to). Like it or not, that's why security measures are in place.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi all!
I have a listNode composed by this two parameters
private Bitmap data;
private ListNode next;
And I have a List with some elements. I have to delete several times my list, and I want to free the memory that bitmap occupies, so I made a function in my list to dispose the bitmaps.
current = firstnode;
while(current.next != lastnode)
{
current.data.dispose();
current = current.next;
}
current.data.dispose();
But when I run this functions and with the help of task manager it seems that memory is always increasing. How can I delete imediatly the bitmaps from memory?! Is it possible?!
Thank you all, Sérgio
|
|
|
|
|
You don't have to. You've already .Dispose d the objects, now you have to wait for the Garbage Collector to actually free the memory, and that can take a while. You COULD call GC.Collect() , but it's NOT recommended because you can actually degrade the performance of your app considerably using it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Memory reclaimation is technically "expensive" since it has to lock the references as they are, figure out what is ready to release, do optional stuff like compact, etc. So it is not done unless it is necessary (like low memory) or when it is sure you are idle (often it happens when you minimize) or when you explicitly call System.GC.Collect .
Because you are using a memory managed runtime, you shouldn't care when or how garbage collection happens as long as you Dispose is used correctly. Constantly calling System.GC.Collect slows your application down so if you have to use it please use it in the correct place.
|
|
|
|
|
I have this function QuickFindModules in the dll QuickFind.dll, now I want to use this unmanaged function in my c# code, can somebody show me the best way to do it. Here is the signature.
int QuickFindModules(char* nameList, long bufferLength)
Here is how I pinvoked it..
[DllImport("quickfind.dll", CharSet = CharSet.Ansi)]
public static extern int QuickFindModules([Out]StringBuilder nameList, long bufferLength);
...
StringBuilder nameList = new StringBuilder(512);
long length = 512;
int result = QuickUsbFindModules(nameList, length);
string temp = nameList.ToString();
Was I correct to change the char*, to a StringBuilder. What did I do wrong?
/\ |_ E X E GG
|
|
|
|
|
An unmanaged long is not the same as a managed long . You're pushing the relevent data in your numeric expression off the deep end of the call stack, so it won't be read. What that means is that the unmanaged function implementation will always see 0 as the bufferLength .
You can declare a StringBuilder for a char* , yes. Since a char* is always an Ansi string and you specified such with the DllImportAttribute.CharSet field, you should make sure that QuickFindModules doesn't have ANSI and Unicode support like most Microsoft APIs do (functions ending in "A" or "W" for ANSI and Unicode, respectively). If it does, add "A" to the end and set ExactSpelling to true in your DllImportAttribute declaration.
Finally, never expose P/Invoke methods as public unless the defining type is internal. Callers - even within your own project - should not be able to simply call P/Invoke methods. Remember, P/Invoke calls into unmanaged code. There are ways to actually crash the CLR. You should expose this functionality by encapsulating it into a public method like I have below.
The correct declaration and call should look something like this:
[DllImport("quickfind.dll", CharSet=CharSet.Ansi)]
static extern int QuickFindModules(
[Out] StringBuilder nameList,
int bufferLength);
public string FindModules()
{
int length = 512;
StringBuilder nameList = new StringBuilder(length);
if (QuickFindModules(nameList, length) == 0)
return nameList.ToString();
return null;
} You could also just use a string here, too, and initialize it correctly like so:string nameList = new string('\0', length); .
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|