Use the attached TLC\'s Real Estate database, OR create a Microsoft Access datab
ID: 3834143 • Letter: U
Question
Use the attached TLC's Real Estate database, OR create a Microsoft Access database that contains one table named tblHomes. The table should contain 10 records, each having six fields. The ID, City, and state fields should contain text. The number bedrooms, number of bathrooms fields should be numeric. The Price field should be currency.
Create an application that displays the contents of the database in a DataGridView control. If necessary, remove the BindingNavigator control from the application. The application should allow the user to insert and delete records. It should also allow the user to display the records for a specific number of bedrooms, a specific number of bathrooms, a specific City, and a specific combination of bedrooms and bathrooms.
This is for Visual Basic.
Explanation / Answer
using System.Data; using System.Data.SqlServerCe; using System.Windows.Forms; namespace WindowsFormsApplication5 { public partial class Form1 : Form { public Form1() { InitializeComponent(); FillData(); } void FillData() { // 1 // Open connection using (SqlCeConnection c = new SqlCeConnection( Properties.Settings.Default.DataConnectionString)) { c.Open(); // 2 // Create new DataAdapter using (SqlCeDataAdapter a = new SqlCeDataAdapter( "SELECT * FROM Animals", c)) { // 3 // Use DataAdapter to fill DataTable DataTable t = new DataTable(); a.Fill(t); // 4 // Render data onto the screen dataGridView1.DataSource = t; } } } } }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.