|
I faced the same problem, thanks
modified 1-Aug-19 21:02pm.
|
|
|
|
|
hi
How to pass any text value from form to Crystal Report ?
ex: i need to pass "hellow" from Form1 to my Crystal Report , how to do it ?
(working in C#)
thank's in advance
|
|
|
|
|
You create paramaters in crystal report. via that parameters u can pass
___________
rptCount = New ReportDocument
rptCount.Load(Server.MapPath("reportname.rpt"))
''Get the collection of parameters from the report
crParameterFieldDefinitions = rptCount.DataDefinition.ParameterFields
''Access the specified parameter from the collection
crParameter1 = crParameterFieldDefinitions.Item("Param1")
crParameter2 = crParameterFieldDefinitions.Item(“Param2")
''Get the current values from the parameter field. At this point
''there are zero values set.
crParameter1Values = crParameter1.CurrentValues
crParameter2Values = crParameter2.CurrentValues
''Set the current values for the parameter field
crDiscrete1Value = New ParameterDiscreteValue
crDiscrete1Value.Value = Request.Form(“param1value“)
crDiscrete2Value = New ParameterDiscreteValue
crDiscrete2Value.Value = Request.Form(“param2value“)
''Add the first current value for the parameter field
crParameter1Values.Add(crDiscrete1Value)
crParameter2Values.Add(crDiscrete2Value)
''All current parameter values must be applied for the parameter field.
crParameter1.ApplyCurrentValues(crParameter1Values)
crParameter2.ApplyCurrentValues(crParameter2Values)
|
|
|
|
|
Hello,
I have this structure :
Firstname; adresse; lastName
Aubenque; 20 wallstreet; Julien
Aubenque; 23 wallstreet; Julien
Bachelot; 22 londres street ; Maud
Aubenque; 25 wallstreet; Julien
Bachelot; 24 londres street ; Maud
Bachelot; 28 londres street ; Maud
Aubenque; 20 wallstreet; Julien
Bachelot; 22 londres street ; Maud
I would get the lines where the firstname and lastname was the same, help met to resolve this great problem, thank you verry mutch.
|
|
|
|
|
I didn't understand your problem. Can you explain it?
|
|
|
|
|
I am sorry, ok
I would get all line where the lastname and lastname was the same, i will get two elements for exemple in arraylist :
the first :
Aubenque; 20 wallstreet; Julien
Aubenque; 23 wallstreet; Julien
Aubenque; 25 wallstreet; Julien
Aubenque; 20 wallstreet; Julien
the second :
Bachelot; 22 londres street ;Maud
Bachelot; 24 londres street ; Maud
Bachelot; 28 londres street ; Maud
Bachelot; 22 londres street ; Maud
Thank you verry mutch
|
|
|
|
|
abbd wrote: I would get all line where the lastname and lastname was the same, i will get two elements for exemple in arraylist :
I am really sorry but i still didn't got your question.
What actually you need?
|
|
|
|
|
|
I need a book which describes about programming Microsoft windows.
I am using C#. I am reasonably sound in C (MCU work).
I can understand easily the syntax and structures in C#. But what confuses me is the many concepts like messages events. Also many terminologies like Guid, API functions etc.
I think I need a book to learn about the basics of windows programming.
C# books are not going much into that. They are teaching C# to a windows programmer.(At least I think So!)
Please suggest
With Regards
Roy Thomas
"..this file is known as source file probably because it is a source of frustration and anxiety!" - Chuck Sphar - In book 'C# 2005 for Dummies'.
|
|
|
|
|
|
I have Front End Microsoft C# 2005 Windows Application and Back End SQL Server 2005 Express Edition. I want to access SQL Server Express Data Base which is reside in one Computer, from 5 different location computers for adding and updating etc; records in Local Network Area.
Please guide me, how can I done the job.
|
|
|
|
|
|
hi.
How can I return IEnumerable<t> az a method parameter.
In fact I want to return a table records. but I must return as IEnumerable<t>;
How can I fill IEnumerable and return it?
|
|
|
|
|
Hi,
you have to write a class that will implement the IEnumerable interface. Within the implementation you can move through your records.
Have a look here:
http://msdn.microsoft.com/en-us/library/system.collections.ienumerable%28VS.80%29.aspx[^]
By the way, if you are using the System.Data.Table then the Rows-Property offers a GetEnumerator() method which will return an enumerator for the records within the table.
Regards
Sebastian
|
|
|
|
|
a world of thanks.
I 'll try to do it
|
|
|
|
|
Other than that, you can also use any class implemented from IEnumerable like Array, ArrayList, List etc... to return IEnumerable object.
|
|
|
|
|
Use a yield[^] keyword to return records as they go.
IEnumerable<int> GetNumbers()
{
for (int i = 0; i < 100; i++)
yield return i;
} Now you can do:
foreach (int number in GetNumbers())
Console.WriteLine(number);
Greetings - Jacek
|
|
|
|
|
I am getting an error message like this 'Object reference not set to an instance of an object' when I try to invoke an assembly method dynamically. Please refer to the attached code snippets.
I need forum's help to solve this problem.
The main code snippet.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using myClassLibrary;
namespace DynamicallyLoadAssembly
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Assembly assembly;
MethodInfo method;
Type type;
string sPath = @"F:\VS2005 Projects\myClassLibrary\myClassLibrary\bin\Debug\myClassLibrary.dll";
int val1 = 7;
int val2 = 5;
try
{
assembly = Assembly.LoadFile(sPath);
type = assembly.GetType("myClassLibrary.myClass");
Type[] p = new Type[3];
p[0] = Type.GetType("System.Int32");
p[1] = Type.GetType("System.Int32");
p[2] = Type.GetType("System.Int32&");
method = type.GetMethod("Method1", p);
Object[] ps = new Object[3] { val1, val2, 0 };
method.Invoke(null, ps);
MessageBox.Show("ps = " + ps[2].ToString());
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
}
}
private void button2_Click(object sender, EventArgs e)
{
Assembly assembly;
MethodInfo method;
Type type;
string sPath = @"F:\VS2005 Projects\myClassLibrary\myClassLibrary\bin\Debug\myClassLibrary.dll";
int val2 = 5;
try
{
assembly = Assembly.LoadFile(sPath);
type = assembly.GetType("myClassLibrary.myClass");
Type[] p = new Type[3];
p[0] = Type.GetType("System.Enum");
p[1] = Type.GetType("System.Int32");
p[2] = Type.GetType("System.Int32&");
method = type.GetMethod("Method1", p);
Object[] ps = new Object[3] { myClass.myEnum.One, val2, 0 };
// The error 'Object reference not set to an instance of an object' occurs when invoking this method.
method.Invoke(null, ps);
MessageBox.Show("ps = " + ps[2].ToString());
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
}
}
}
}
The library code snippet.
using System;
using System.Collections.Generic;
using System.Text;
namespace myClassLibrary
{
public class myClass
{
public enum myEnum : int
{
One,
Two,
Three
};
public static void Method1(int a, int b, out int c)
{
c = a + b;
}
public static void Method2(myEnum a, int b, out int c)
{
c = 0;
switch (a)
{
case myEnum.One:
c = 1 + b;
break;
case myEnum.Two:
c = 2 + b;
break;
case myEnum.Three:
c = 3 + b;
break;
}
}
}
}
Thanks
Chris
|
|
|
|
|
Hi,
you are passing "null" as the first parameter to method.Invoke. But the first parameter is the required instance that the method will be executed on. The instance must be an object of the type you loaded dynamically. So before calling invoke you have to create an object from the type "myClassLibrary.myClass". This can be done by reflection also, using the constructor.
Have a look here:
http://msdn.microsoft.com/en-us/library/system.type.getconstructor.aspx[^]
Regards
Sebastian
|
|
|
|
|
Hi Sebastian,
Thanks for the answer, but I still do not understand how to fix.
I am not a pro programmer. Please explain with example...
thanks
|
|
|
|
|
Hi,
rewrite the invocation like this:
method = type.GetMethod("Method1", p);
object myObject = Activator.CreateInstance(type);
Object[] ps = new Object[3] { val1, val2, 0 };
method.Invoke(myObject, ps);
This will create an instance named myObject and invokes the method "method1" on that instance.
Regards
Sebastian
|
|
|
|
|
Thanks Sebastian for your quick response. Anyhow I managed to solve this problem by changing a single line at the button2_Click method, as shown below.
Previous code:
p[0] = Type.GetType("System.Enum");
Now changed to:
p[0] = assembly.GetType("myClassLibrary.myClass+myEnum");
Thanks
Chris
|
|
|
|
|
You try to invoke a non-static method on a null object. Create an instance of the class the Type represents by using Activator.CreateInstance, and pass that instead of null.
|
|
|
|
|
I already have a code for my linked list. How do I connect notepad to c# to make it as a simple database of my program?
|
|
|
|
|
Hi,
do you mean notepad? The windows notepad? This is just an application to edit files. Do you want to store your data within a file? Then think about using a format like csv. How is the linked list connected to this? What do you want to store exactly?
Regards
Sebastian
|
|
|
|