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.SqlClient;
namespace Ctest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private SqlConnection cnn;
private SqlDataAdapter da;
private void ok_Click(object sender, EventArgs e)
{
string strConnection = "user id=sa;password=123456;";
strConnection += "initial catalog=stock;Server=(local);";
strConnection += "Connect Timeout=30";
cnn = new SqlConnection(strConnection);
da = new SqlDataAdapter("select * from 物料清单",cnn);
DataSet ds=new DataSet();
DG.DataSource = ds;
da.Fill(ds);
}
}
}
------解决方案--------------------
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.SqlClient;
namespace Ctest { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
private SqlConnection cnn; private SqlDataAdapter da;