C/S中的C#初学者遇到一个小问题
主窗品Form1,也是容器,代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace xuesan
{
public partial class xuesan : Form
{
private static OleDbConnection conn = null;
public xuesan()
{
InitializeComponent();
}
public static OleDbConnection getConnection()
{
if(conn==null)
{
conn = new OleDbConnection( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=123.mdb "); //HrSalary
conn.Open();
}
return conn;
}
private void button1_Click(object sender, EventArgs e)
{
Form2 p = new Form2();
p.ShowDialog();
}
public bool has(string formName)
{
bool result = false;
for (int i = 0; i < this.MdiChildren.Length; i++)
{
if (this.MdiChildren[i].Name == formName)
{
result = true;
break;
}
&nbs