level 1
毁灭吧末日!
楼主
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;
using System.Data.SqlClient;
namespace WpfApplication1
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
{
}
private void button1_Click(object sender, RoutedEventArgs e)
{
try{
String cph=textBox1.Text;
String sqlcon1 = "Data Source=192.168.0.67;database=xncsbgcc,Uid=root;Pwd=root;";
SqlConnection Conn1 = null;
Conn1 =new SqlConnection(sqlcon1);
MessageBox.Show("连接SQL数据库成功");
Conn1.Open();
MessageBox.Show("连接SQL数据库成功");
MessageBox.Show("连接SQL数据库成功");
DataSet ds = new DataSet();
MessageBox.Show("连接SQL数据库成功");
String sect = "select * from zdxncs where cph="+cph;
MessageBox.Show("连接SQL数据库成功");
SqlDataAdapter da = new SqlDataAdapter(sect ,Conn1);
MessageBox.Show("连接SQL数据库成功");
da.Fill(ds);
MessageBox.Show("连接SQL数据库成功");
Conn1.Close();
}
catch {
MessageBox.Show ( "连接SQL数据库发生错误!" ) ;
}
}
}
}
2014年12月12日 00点12分
1
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;
using System.Data.SqlClient;
namespace WpfApplication1
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
{
}
private void button1_Click(object sender, RoutedEventArgs e)
{
try{
String cph=textBox1.Text;
String sqlcon1 = "Data Source=192.168.0.67;database=xncsbgcc,Uid=root;Pwd=root;";
SqlConnection Conn1 = null;
Conn1 =new SqlConnection(sqlcon1);
MessageBox.Show("连接SQL数据库成功");
Conn1.Open();
MessageBox.Show("连接SQL数据库成功");
MessageBox.Show("连接SQL数据库成功");
DataSet ds = new DataSet();
MessageBox.Show("连接SQL数据库成功");
String sect = "select * from zdxncs where cph="+cph;
MessageBox.Show("连接SQL数据库成功");
SqlDataAdapter da = new SqlDataAdapter(sect ,Conn1);
MessageBox.Show("连接SQL数据库成功");
da.Fill(ds);
MessageBox.Show("连接SQL数据库成功");
Conn1.Close();
}
catch {
MessageBox.Show ( "连接SQL数据库发生错误!" ) ;
}
}
}
}