|
Yes, I used stored procs, always, and then call them from a data layer ( a seperate dll that handles all database calls )
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Attach the profiler to SQL server and see what query (if any) actually gets executed by your app.
|
|
|
|
|
Why start a new thread? You already have a thread about this.
Where do you execute the command?
---
single minded; short sighted; long gone;
|
|
|
|
|
what you mean by start a new thread
adap.InsertCommand = cmd;
Should i write something else to save the Data in th database
Assaf
|
|
|
|
|
He means that you asked the same queston again instead of staying where you asked it before.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Assaf82 wrote: adap.InsertCommand = cmd;
Should i write something else to save the Data in th database
That is just putting the command in an adapter. You have to do something to execute the command.
---
single minded; short sighted; long gone;
|
|
|
|
|
|
Again, google would have answered this long ago. Don't use stuff you don't understand, research it first.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Google for ExecuteNonQuery. All you have done is write code that could insert data into the database - you haven't actually told the runtime to perform the insert.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I know entity class name as string ( e.q. "Customer", "Product")
I need to invoke static method in this entity class.
I tried the following code but got compile error shown in comment.
How to invoke static method when type name is known as string ?
using System.Collections.Generic;<br />
using System;<br />
<br />
class TestApplication {<br />
<br />
static void Main() {<br />
FindByTypeName("Customer");<br />
FindByTypeName("Product");<br />
}<br />
<br />
static object[] FindByTypeName(string typename) {<br />
<br />
Type t = Type.GetType(typename);<br />
ActiveRecordBase<object> entity = (ActiveRecordBase<object>)<br />
System.Activator.CreateInstance(t);<br />
<br />
return entity.FindAll();<br />
<br />
}<br />
<br />
}<br />
<br />
class Customer : ActiveRecordBase<Customer> {}<br />
<br />
class Product : ActiveRecordBase<Product> {}<br />
<br />
public class ActiveRecordBase<T> {<br />
public static T[] FindAll() {<br />
return null;<br />
}<br />
}
Andrus
|
|
|
|
|
You invoke static methods on the object itself, not a specific instance of that object. In your case, you don't need the FindByTypeName method or call. Instead, you would want to do this:
static void Main()
{
Customer[] customers = Customer.FindAll();
Product[] products = Product.FindAll();
}
|
|
|
|
|
Thank you.
I read class name ( Customer, Products etc) from database.
Some class names are not known at design time.
So I cannot use hard coded class names.
How to invoke method if class name is passed as string to this procedure ?
Andrus
|
|
|
|
|
reflection, I guess
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thank you. Itried reflection but got assertion failed error.
What I'm doing wrong ?
using System.Collections.Generic;<br />
using System;<br />
using System.Windows.Forms;<br />
<br />
class TestApplication {<br />
static void Main() {<br />
MessageBox.Show(FindByTypeName("Customer").ToString());<br />
}<br />
<br />
static object[] FindByTypeName(string typename) {<br />
Type t = Type.GetType(typename);<br />
System.Reflection.MethodInfo mi = t.GetMethod("FindAll",<br />
System.Reflection.BindingFlags.Static);<br />
<br />
System.Diagnostics.Debug.Assert(mi != null);<br />
object[] entity = (object[])mi.Invoke(null, null);<br />
return entity;<br />
}<br />
}<br />
<br />
class Customer : ActiveRecordBase<Customer> {<br />
}<br />
<br />
class Product : ActiveRecordBase<Product> {<br />
}<br />
<br />
public class ActiveRecordBase<T> {<br />
public static T[] FindAll() {<br />
return null;<br />
}<br />
}
Andrus
|
|
|
|
|
I think you need to supply both BindingFlags.Static | BindingFlags.Public to GetMethod.
|
|
|
|
|
With .NET 2.0, it's noted that accessibility of classes need not be defined, since classes can be inherited within the same assembly.
When the superclass is given accessibility as public, the program runs successfully. However setting the inherited class as public, error messages are displayed:
public class myClass : TestConsole.MainConsole
Error: Inconsistent accessibility: base class 'TestConsole.MainConsole' is less accessible than class 'TestConsole.myClass'
What is the default accessibility level when it is not explicitly defined?
For example the following code is successfully built:
Program.cs
--------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace TestConsole
{
class MainConsole
{
public const int myAge = 27;
public int returnZero()
{
return 0;
}
static void Main(string[] args)
{
Console.WriteLine("Start program");
}
}
myClass.cs
---------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace TestConsole
{
class myClass : TestConsole.MainConsole
{
private int Age;
public myClass()
{
Age = base.returnZero();
}
}
}
Jon
|
|
|
|
|
coz the Child Class is Default (Private) u change Change
class myClass : TestConsole.MainConsole
into
Public class myClass : TestConsole.MainConsole
|
|
|
|
|
The default accessibility is always private. This applies to classes, methods, properties, and fields.
In your code sample, defining MainConsole with out specifying the accessibility makes it private. However, the problem you are running into isn't the accessibility on the class since in this case, they are both private.
In MainConsole you do not have a default constructor, so the compiler is generating one for you. The compiler generated constructor is always private. When you then try to derive MyClass from it, MyClass has a public constructor. What the compiler sees is that you have a class with a public constructor inheriting from one with a private constructor and says that there is no way for the derived class to create an instance of the base class. (If something is private, even the derived classes don't have visibility to it.)
[modification 13:28 Tuesday 4th September, 2007]
I was wrong on this response, not sure what I was thinking. See this response: http://www.codeproject.com/script/comments/forums.asp?forumid=1649&select=2209501&mpp=50&fr=354&df=100#xx2209501xx[^]
[/modification]
|
|
|
|
|
|
Hmmm, default accessibility for classes and structs is internal, nested classes and structs are private. If you create no constructors for a class it will have a default public constructor.
The error he gets is because MainConsole is internal and he creates a public class that inherits from it.
|
|
|
|
|
You're right...I'm not sure what I was thinking when I wrote that response.
|
|
|
|
|
Default accessibility is private for everything but namespace elements.
That means classes, structs, delegates or enums that are not defined within another class are by default internal. In all other cases accessibility defaults to private.
In your case, the myClass and MainConsole classes are internal.
|
|
|
|
|
|
how van i change default printer page size to A6? i got printer name from installedprinters and i want to change page size of it to A6
thank you
|
|
|
|
|