Community Sites
Create your own community website and start earning today !
It's Free !
 
Communities Members BookmarksPolls Fresher Jobs Funny Photos B.Tech Projects New Member FAQ  



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

website counter



ADO.NET


Posted Date: 24 Mar 2008    Resource Type: Articles/Knowledge Sharing    Category: Placement Papers

Posted By: ramya       Member Level: Gold
Rating:     Points: 5




ADO.NET

#1. How to bind two controls to the same DataTable without having changes in one control also change the other control?

This is very common problem, as a newcomer I had spent great deal of time to solve this. Suppose you have two controls viz, Combobox and Listbox on same form and Datasource property of both these controls is same. Then the selection in one control selects same item in other control. This problem occurs because of BindingContext property of controls. By default the BindingContext member of each of the two controls is set to the Form's BindingContext. Thus, the default behavior is for the ComboBox and Listbox to share the same BindingContext, and that's why the selection in the ComboBox is synchronized with the current item of Listbox. If you do not want this behavior, create a new BindingContext member for at least one of the controls.
comboBox1.DataSource = dataset.Tables[ "Items" ];
comboBox1.ValueMember = "CustomerID";
comboBox1.DisplayMember = "CustomerID";

listBox1.BindingContext = new BindingContext(); // Set the BindingContext property of ListBox to new BindingContext
listBox1.DataSource = dataset.Tables[ "Items" ];
listBox1.ValueMember = "CustomerID";
listBox1.DisplayMember = "CustomerID";
Crystal Reports
#1. How to hide the status bar of Crystal Report in Report Viewer?

The following block makes the status bar of Crystal Report invisible.
foreach(object obj in this.crystalReportViewer1.Controls)
{
if( obj.GetType()== typeof(System.Windows.Forms.StatusBar))
{
StatusBar sBar=(StatusBar)obj;
sBar.Visible=false;
}
}
#2. How to generate PDF version of Crystal Report programmatically?

Following block of code generates PDF version of Crystal Report programmatically.
ReportDocument O_Report=new ReportDocument();
ExportOptions exportOpts = new ExportOptions();
PdfRtfWordFormatOptions pdfFormatOpts = new PdfRtfWordFormatOptions ();
DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();

exportOpts = O_Report.ExportOptions;

// Set the PDF format options.
exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat;
exportOpts.FormatOptions = pdfFormatOpts;

// Set the disk file options and export.
exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
diskOpts.DiskFileName = "C://Trial.pdf"; // This is the path where the file will be saved
exportOpts.DestinationOptions = diskOpts;

O_Report.Export ();
#3. How to select a printer while printing through Crystal Report programmatically?

You can accomlish this using PrintDialog control and get the computer name using printDialog1.PrinterSettings.PrinterName
// Create a Report Document
ReportDocument O_Report=new ReportDocument();
private void btnPrint_Click(object sender, System.EventArgs e)
{
try
{ // Create a Print Dialog
PrintDialog printDialog1 = new PrintDialog();

// Create a Print Document
PrintDocument pd = new PrintDocument();

printDialog1.Document=pd;
printDialog1.ShowNetwork=true;
printDialog1.AllowSomePages=true;

DialogResult result = printDialog1.ShowDialog();
if (result == DialogResult.OK)
{
PrintReport(printDialog1.PrinterSettings.PrinterName);
}
}

catch(Exception ex)
{
MessageBox.Show(ex.Message);
}

}
private void PrintReport(string printerName)
{
// Select the printer.
O_Report.PrintOptions.PrinterName = printerName;

/* Print the report. Set the startPageN and endPageN
parameters to 0 to print all pages.*/
O_Report.PrintToPrinter(1, false,0,0);
}
Deployment
#1. How to install database while deploying .NET application ?

Solution 1
Solution 2
#2. How to install MSDE while deploying .NET application?

Installing MSDE with .NET Application
#3. How to create conditional shortcuts while deploying .NET application?

Creating Conditional shortcuts
Miscellaneous
#1. How to enable the mnemonics (underline) being displayed when an application is launched

Usually the underline appears only after you press the Alt Key, but you can enable it by changing the Operating System Settings. On Windows XP, Right Click Desktop to bring up the Display Properties Dialog and then choose Appearance tab and then the Effects Button and uncheck the checkbox "Hide Underlined letters for keyboard navigation until I press the ALT Key".
#2. An easy way to build connection string.

Though this in not related to .NET directly but it is useful while working with ADO.NET
1) Open a New notepad and save it with "udl" extension, suppose "New.udl".
2) Now you will see that it's icon is changed.
3) Open it, you will find Data Link properties dialog box.
4) For SQl Server connection string select Microsoft OLE DB Provider For SQL Server in Provider Tab.
5) Click button "Next" or select Connection Tab
6) Here you can select all connection details and press button
Test Connection. If it is successful close this dialog box.
7) Now open this file using "Notepad", you will find the connection string. Though it is built for OLE DB
type of connection, you can use for SQL Server connection by removing Provider attribute.

NOTE: If you are using SQL Authentication with password, then check the checkbox Allow Saving Password.
This is necessary so that password appears in connection string.









Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: ASP.NET Interview Questions – IV
Previous Resource: ASP.NET DataSet Tips & Tricks
Return to Discussion Resource Index
Post New Resource
Category: Placement Papers


Post resources and earn money!
 
Related Resources



Watch TV Channels
  • Watch Asianet TV online
  • Kairali TV in Internet
  • Surya TV online
  • Amritha TV Channel

  • Contact Us    Privacy Policy    Terms Of Use   

    SpiderWorks Technologies Pvt Ltd. 2006 - 2007 All Rights Reserved.