请教个连接问题,谢谢
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data.SqlClient;
using System.Data;
namespace FirstWPF
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
SqlDataAdapter sda;
DataTable dt;
void getData()
{
//sqlconnection:
SqlConnectionStringBuilder connsb = new SqlConnectionStringBuilder();
connsb.DataSource = "";
connsb.IntegratedSecurity = true;
connsb.InitialCatalog = "DogDatas";
//start make sql query
SqlConnection conn = new SqlConnection(connsb.ConnectionString);
sda = new SqlDataAdapter("select id,dogID,userName,companyName,xlNumber from tb_dogdatas where id<=10;", conn);
SqlCommandBuilder commbld = new SqlCommandBuilder();
sda.UpdateCommand = commbld.GetUpdateCommand();
dt = new DataTable();
sda.Fill(dt);
listView1.ItemsSource = dt.DefaultView;
}
private void button1_Click(object sender, RoutedEventArgs e)
{
getData();
}
}
}
这里怎么写connsb.DataSource = ""? 调试了几下连接不上,新手求指导
我的实例是这个样子:
[ 本帖最后由 tianqy 于 2013-3-20 11:43 编辑 ]