|
for this u can use crystalreport and file and add parameter field
and create
ParameterFields myParams = new ParameterFields();
ParameterField myParamGuestName = new ParameterField();
ParameterDiscreteValue myDiscreteValue = new ParameterDiscreteValue();
myParamGuestName.ParameterFieldName = "guestname";
myParams.Add(myParamGuestName);
crystalReportViewer.ParameterFieldInfo = myParams;
enjoy this code
diwaker sharma
|
|
|
|
|
sorry dude, i cant understand .. i have crystal report in my file ... where i write these code ?
Do i need to fill dataset ?
My existing code is like this ..
private void button1_Click(object sender, EventArgs e)
{
sqlDataAdapter1.Fill(dataSet11);
crystalReport11.SetDataSource(dataSet11);
crystalReportViewer1.ReportSource = crystalReport11;
}
|
|
|
|
|
|
First you need to add a parameter to your report.
Then (still in the report) add a select query (from memory: right click report - set select - choice your ID column and set equal to parameter)
Then in code you do:
<br />
private void button1_Click(object sender, EventArgs e)<br />
{<br />
sqlDataAdapter1.Fill(dataSet11);<br />
crystalReport11.SetDataSource(dataSet11);<br />
crystalreport11.setparameter("parametername",value);<br />
crystalReportViewer1.ReportSource = crystalReport11;<br />
<br />
}<br />
This is all from memory so you might have to search a bit
O and nobody is going to just write the code for you. But this should help you on your way.
|
|
|
|
|
System.Data.SqlClient.SqlException was unhandled
Message="Parameterized Query '(@A varchar(50))SELECT DS.*\r\nFROM DS\r\nWHERE (A =' expects parameter @A, which was not supplied."
Source=".Net SqlClient Data Provider"
ErrorCode=-2146232060
I get this error in this line
---- sqlDataAdapter1.Fill(dataSet11);
What I did is ... Added a textbox1, button1, crystalreportviewer1 and crystalreport11, crystalreport.rpt..
in crystalreport.rpt, I added a Parameter Field , named "AAAA" and in Set Select Editor, I set equal to parameter and added A=@A in formula editor.. Then i write this code and error happens..
sqlDataAdapter1.Fill(dataSet11);
crystalReport11.SetDataSource(dataSet11);
crystalReport11.SetParameterValue("AAAA", textBox1.Text);
crystalReportViewer1.ReportSource = crystalReport11;
|
|
|
|
|
hey .. just worked tom .. thanks a lot my friend ...
can i have your messenger id if you dont mind ...
|
|
|
|
|
|
It looks like you are trying to fill your dataset with an select query that requires an variable (@A)
Wich is missing. (that is what the error says)
first off all this isn't needed.
You have 2 options:
You select the complete table and do the filtering on the report (that is the way I explained it in earlyer post)
OR
You do the filtering in the select command and NOT on the report (in this case you don't need the parameter on the report)
Both are possible and acceptable, you can do both but that's not needed.
If you choice the second option you need to provide a sqlparameter
something like:
sqldataadapter1.selectcommand.commandtext = "SELECT * FROM table WHERE id=@A";
sqldataadapter1.selectcommand.parameters.addwithvalue("@A",textbox1.text);
sqldataadapter1.fill(dataset11);
crystalReport11.SetDataSource(dataSet11);
crystalReportViewer1.ReportSource = crystalReport11;
and then your report doesn't need the parameter nor needs to filer it (the set select from last post) since you already filterd the data.
(once again this if from memory)
|
|
|
|
|
Another problem, suppose there are two AgentID ... If i enters one agent Id and search for it , it works fine, but when i changes the value in textbox and enters 3nd agent id, it throws an error The SelectCommand property has not been initialized before calling 'Fill'.
I have to search agentid and my search changes frequently .. so its not happing now..
Please suggest something.
|
|
|
|
|
Did you set the selectcommand?
sorry without your code I can't really say what's wrong with it
post your code that you use to fill the dataset
|
|
|
|
|
Hello Sir, actually I use SqlDataAdapter and generate dataset not by coding .. should i do by coding ? I did everything from wizard ..
sqlDataAdapter1.Fill(dataSet11);
crystalReport11.SetDataSource(dataSet11);
crystalReport11.SetParameterValue("AAAA", textBox1.Text);
crystalReportViewer1.ReportSource = crystalReport11;
|
|
|
|
|
Is this all your code?
Where is your SQL string?
The error message you get suggests that the selectcommand from your sqldataadapter isn't set wich from what I can see it isn't.
to set the selectcommand:
sqldataadapter.selectcommand.commandtext= "SELECT [insert your column names here] FROM [insert table name] WHERE [productid]= @id"
sqldataadapter.selectcommand.parameters.addwithvalue("@id",textbox1.text)
sqlDataAdapter1.Fill(dataSet11);
crystalReport11.SetDataSource(dataSet11);
crystalReportViewer1.ReportSource = crystalReport11;
|
|
|
|
|
Hi,
How can we get all workgroups on LAN also computers in that workgroup.
Thanks,
Venky.
venki
|
|
|
|
|
|
Thnaks,
But it gives only our system workgroup but i want all workgroups available on LAN
venki
|
|
|
|
|
hello all
i treid the code below but nothing happens....
//in button write
serialPort1.PortName = "COM1";
serialPort1.BaudRate = 9600;
serialPort1.DataBits = 8;
serialPort1.Parity = Parity.None;
serialPort1.StopBits = StopBits.One;
serialPort1.Open();
serialPort1.Write("A");
serialPort1.Close();
// in Button Read
serialPort1.Open();
textBox1.Text = serialPort1.ReadLine();
|
|
|
|
|
You asked the same question 20 minutes ago. Why are you double-posting? It's rude. You'd better read the documentation instead of double posting.
|
|
|
|
|
Like I said below:
What are you expecting to happen? You can't just write "A" to a serial port and then expect to read it back.
You need to have some hardware connected to the serial port that either responds to data, or transmits data in.
(Stop reposting questions, you'll only annoy everyone and get the same answers)
Simon
|
|
|
|
|
hello Simon Stevens
my requirement is to connect a microcontrolelr to the serial port .
i tried this to see if data is in the buffer ... then it can't be read back
Thanks
|
|
|
|
|
You need to read your micro controllers docs.
Simon
|
|
|
|
|
hello Simon Stevens
first i need to download some data to the microcontroller from my application ... the microcontroller is connected to the Serial port.
When the Microcontroller receives the data it executes its and it returns some data.. at this time i expect this data be in the port and need to read ir from the serial port
i await for u r suggestions on this
Thanks
|
|
|
|
|
TJS4u wrote: i treid the code below but nothing happens....
That's incorrect, as something did happen. Either you didn't see it happen, or you didn't understand what happens.
The serial port doesn't "remember" that you sent an "A", since there is no memory attached to the serial port. Did you get an exception, or did the serial-port just 'eat' the information you sent?
Same problem with reading from the serial port. If there isn't anything attached and sending messages, then there won't be anything to read from the port.
Your best option would be going out to buy a "null-modem cable", or something that can echo the signals from the serial port.
I wish you lots of luck, as you are going to need it 
|
|
|
|
|
hello Eddy Vluggen
i am new to C#.. so asking such questions...
the code is executing and when it enters the line
string line=...................
the system hangs
wht to do next
How can i be sure that the port is enabled and data has been send to the port...
OR if i connect a device will that respond to the code i have written
i await u r suggestions
Thanks
|
|
|
|
|
TJS4u wrote: the system hangs
No, it's not hanging, but waiting. Waiting for someone to send a carriage-return + linefeed to the serial port. In other words, the system is reading from the serial port, and will continue reading, until someone sends an "enter" to the serial port.
TJS4u wrote: How can i be sure that the port is enabled and data has been send to the port...
Make yourself a cable that echo's everything.
TJS4u wrote: if i connect a device will that respond to the code i have written
The device doesn't know about your code. Your code will have to speak to the device in a way that the device itself understands. Various devices use the serial port in different ways. Your micrologger will have some examples on this.
|
|
|
|
|
hello Eddy Vluggen
Thanks for u r reply
still some things makes confusing///
i have written
string line = serialPort1.ReadLine();
At this point will the variable line stores the value from the port???
if a device is connected and it has some thing to return
Thanks
|
|
|
|