|
Hi
I have one rdlc report. It has one text field and one datafield.
I want to show both in report viewer but when I print this report only datafield print .....
Please replay as soon as posible...
Thanks in advance...........
hi...
|
|
|
|
|
Hi All,
I'm after a little guidance regarding SQL database access in C#.
I come from a VB6 background and rightly or wrongly the way i was shown database access with ADO was to open a global connection at the beginning, use it throughout the program and close it down at the end or if a problem occurred.
I understand now that keeping a connection open for the whole time is wrong but i would like to understand what the correct way in C# is.
At the moment i have created a single static connection in a static class and i've set the ConnectionString property at the very beginning though i don't open the connection. Then throughout the program i open the connection, perform the work and then close it afterwards.
Now, should i be doing it this way or should i be creating a new connection at every point where database access is required ? I take it that as long as the ConnectionString remains unchanged (Maybe using a static string to hold the connectionstring), a connection will be taken from the pool??
Is there a preferred or 'Best Practice' way of accessing a database throughout a program?
Thanks in advance.
Matt.
|
|
|
|
|
matbuk wrote: I understand now that keeping a connection open for the whole time is wrong but i would like to understand what the correct way in C# is.
In .NET, not just C#, the guidelines suggest that you open a connection, perform your query and then close the connection. If you have multiple queries to perform in quick succession then you may keep the connection open for those queries.
.NET implements connection pooling so there is negligible performance hit after the connection is opened for the first time. Just ensure that each time you open a connection you use the exact same connection string.
matbuk wrote: Then throughout the program i open the connection, perform the work and then close it afterwards.
Sounds good to me.
matbuk wrote: Now, should i be doing it this way or should i be creating a new connection at every point where database access is required ? I take it that as long as the ConnectionString remains unchanged (Maybe using a static string to hold the connectionstring), a connection will be taken from the pool??
I, personally, use new connection objects but keep the connection string the same.
matbuk wrote: Is there a preferred or 'Best Practice' way of accessing a database throughout a program?
Create a DAL through which you access your database. Don't put database code in the presentation layer.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
Ready to Give up - Your help will be much appreciated.
My website
|
|
|
|
|
Thanks for your very quick response, i have a couple more questions if i may.
If i create a DAL class would i then create an new instance at every point where data access was required? Secondly, if i returned something like a DataSet from the DAL, whould the connection remain open?
Thanks,
Matt.
|
|
|
|
|
matbuk wrote: If i create a DAL class would i then create an new instance at every point where data access was required?
I typically make my DAL classes singletons. It gets created on the first use and then reused throughout.
matbuk wrote: Secondly, if i returned something like a DataSet from the DAL, whould the connection remain open?
DataSets are not connected to the database. So you can safely close the connection once you have the data and return a dataset.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
Ready to Give up - Your help will be much appreciated.
My website
|
|
|
|
|
Excellent. Thanks for your help.
I found this, is this a good place to start?
http://www.codeproject.com/cs/database/SqlWrapper.asp
|
|
|
|
|
Hello,
Does anyone know how can i generate the code to copy one class to another ? the class is not seralizable.
I was thinking implmenting it by recursive reflection that would generate a code (I don't want to use refelction due performance).
Did anyone already implmented it ?
Thanks,
|
|
|
|
|
Hello,
I think implementing IClonable would help you!
Look at this article[^] from Amir Harel.
All the best,
Martin
|
|
|
|
|
I'm drawing Video on a Panel Object using AudioVideoPlayback Class. Now I'd like to put some text (or Image) on it. Any Ideas on how to do that???
Thanks...
|
|
|
|
|
Erhm, do you want to place the text in the video file, or do you just want to render the text over the video when playing ?
|
|
|
|
|
Hi.
I have some classes which I want to serialize to XML Documents.
If there is a field/property in an object of such type and it has a null value, when I serialize the object, the corresponding XML Node is omitted, so it doesn't appear at all in the output document.
Is there a way(I'm thinking maybe a Serialization attribute) to change this behavior so that in the generated XML document, the node appears with an empty value?
Thanks.
|
|
|
|
|
blackjack2150 wrote: he generated XML document, the node appears with an empty value
In the case of a string, How would it distringusish between empty and null?
<XmlNode attribute=""> - here "attribute" is empty
<XmlNode> - here "attribute" is null.
No way around that unless you want to make your value empty rather than null!
|
|
|
|
|
Thanks for the interest.
But it's not about attributes. It's about the value itself.
Let me give you an example:
Say I have the simple class:
class Human
{
public string name;
public int age;
public int height;
public char gender;
}
If I declare a "Human" variable and give values to some of the fields, but not all:
Human John = new Human();
John.name = "John Stevens";
John.age = 23;
I don't give any value to the height and gender fields.
After that I serialize this class to XML.
The output will be:
<xml...>
<Human>
<name>John Stevens</name>
<age>23</age>
</Human>
You notice that there are no tags for height and gender because these values were not initialized.
Bottom line:
Is there a way to get this output xml for the same chain of events as described above?
<xml...>
<Human>
<name>John Stevens</name>
<age>23</age>
<height />
<gender />
</Human>
Thanks.
|
|
|
|
|
Hello all,
I've created a setup project in visual studio 2005 in c#.
When I run the setup.exe to installation folder step, I realized that it installed some other data in system driver-usually drive c (press the Disk Cost button) even if I installed the application in other drive (let's say drive d).
Does anyone knows what's this data?
this data is 1.2 Mb..
RoyRose.
|
|
|
|
|
RoyRose78 wrote: Does anyone knows what's this data?
I don't know. But I do know how to find out: Find some sort of file monitoring tool (sysinternals might be a good place to start) and watch what it is writing to disk.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
Ready to Give up - Your help will be much appreciated.
My website
|
|
|
|
|
I have one RDLC report and it has many value fields(Data fields).
I want to print only this data values but see all report in reportviewer .
Like billing system ......
simplly i have two name see reportviewer but print only one name....
Thanks in advance....
hi...
|
|
|
|
|
Hi,
i'm new in using Crystal Report Viewer..i want to ask how can we bind our data so it can appear in the Crystal Report Viewer, for example: i have a database name Contact and a table name User..what i dont know is bind the data inside table User and view it in our CrystalReportViewer.Please Help me..i use sqlserver2005 for the database
Thank You
Regard,
TCim
|
|
|
|
|
Hi,
I'm a beginer in this language and i hope that there is someone out there who can help me
I want to create a form that has 2 areas. One area is where all the pre-drawn shape is located and the other area allows the shapes to be drag and drop onto it. Any tips what i should do and what kind of classes that i should use?
Thanks
|
|
|
|
|
It's a bit complicated, but you have to set properties into two different objects (sender, receiver):
- Allow Drag
- Allow Drop
Basically you want to drag on object (a shape control) into a container that'll accept the object. It's not that simple, but you do need to handle the events that are triggered by the drag/drop event.
There's a lot of articles/projects on this site that go through drag/drop in detail. I'd take a look at some of that code and adapt it to what you're trying to do. Good luck!
|
|
|
|
|
Hi,
Currently I am working on a multilingual application.
1. I willing provide a Button on UI which will toggle IME mode, say from English to Japanese. How can do that ?
2. How can I detect if systems IME mode is changed by user ?
3. As well as above I want to transliterate the inputed text to english. Can I do it ?
Regards
Prasad
|
|
|
|
|
Erhm, there are several ways to 'translate' your application. I'm also currently working on a project which must be able to support multiple languages. I choose to create a new set of controls to support multiple languages. Therefore created an interface containing translation methods, and make all controls (for example buttons and labels) member of this interface. Then as soon as the user changes the interface language, set the CultureInfo object to the new language, and call the translate method on every control member of the interface
However, VS.NET contains full support for multi-language apps (using resources) you should consider some options, and find 'the best solution' for you
|
|
|
|
|
Thanx Allot Eduard,
I am developing framework for mentioned project now, and I have done with the display part using resource files (i.e. to display label and button text dynamically from resource files). That works fine, problem is with data entry controls like TextBoxes, where IME comes into picture. I wanted to know how can I change IME mode (say from English to Japanese or any Asian language) programatically ?
Awaiting ur reply.
Prasad
|
|
|
|
|
iprasad007 wrote: 1. I willing provide a Button on UI which will toggle IME mode, say from English to Japanese. How can do that ?
All text in the UI is set using the control.Text property on each control. To change the text change that value.
Heres a search for how to use satallite assemblies to achive this.
http://www.google.co.uk/search?hl=en&q=c%23+localisation+satallite+assemblies&meta=[^]
iprasad007 wrote: 2. How can I detect if systems IME mode is changed by user ?
Not sure. You might be able to find out more about this whilst researching localisation.
iprasad007 wrote: 3. As well as above I want to transliterate the inputed text to english. Can I do it ?
It's possible theres some software out there that will do it badly. If you want decent results you'd have to get a human to do it.
Heres some computer translated text. I've no idea if it's mangled or not since I don't read japanese but it should give you an idea of the quality.
English:
This is an example of some computer translated text. It's probably not very good.
Japanese:
これはコンピュータによって翻訳されるテキストの例である。それは非常によくないおそらく。
|
|
|
|
|
Hi originSH,
It seems that u didn't got me correctly. U have told me about Text property of control, but I was talking about setting IME mode. U have told me about translation but I was asking about Transliteration.
Anyways thanx for ur efforts.
Regards
Prasad
|
|
|
|
|