I am creating a databse using access, and all of a sudden, when I run the code, my form is not showing. It was displaying the form just a while ago but now it is not. I did not touch or mess with the program.cs file, by the way. Below is the program.cs file:
namespace P1
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
Below is my database code, if it helps. I have even cut down some code but it is not showing the form at all. However, it is showing that the program is build with no errors.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb;
namespace P1
{
public partial class Form1 : Form
{
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source =d:\DDBS.mdb");
OleDbDataAdapter adap = new OleDbDataAdapter(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source =d:\DDBS.mdb","select * from Student");
DataTable d2 = new DataTable();
DataSet d1 = new DataSet("Student");
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'dDBSDataSet.Student' table. You can move, or remove it, as needed.
//this.studentTableAdapter.Fill(this.dDBSDataSet.Student);
}
private void display_btn_Click(object sender, EventArgs e)
{
adap.Fill(d2);
dataGrid3.DataSource = d2;
}
private void dataGrid1_Navigate(object sender, NavigateEventArgs ne)
{
}
private void button3_Click(object sender, EventArgs e)
{
}
private void form2_btn_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
f2.Show();
}
private void button3_Click_1(object sender, EventArgs e)
{
Form3 f3 = new Form3();
f3.Show();
}
private void button4_Click(object sender, EventArgs e)
{
Form4 f4 = new Form4();
f4.Show();
}
private void next_btn_Click(object sender, EventArgs e)
{
}
private void dataGrid2_Navigate(object sender, NavigateEventArgs ne)
{
}
private void dataGrid3_Navigate(object sender, NavigateEventArgs ne)
{
}
}
}
The setting output type of form:
CodePudding user response:
It looks like you've commented out the line that shows the form. In your bottom sample code there's a Form1_Load
method, the line above the TODO
is the line you'd want.
CodePudding user response:
I think your problem is your setting output type is Console Application or Class Library. You should change is to Application Form.