using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
DataSet myDataSet = new DataSet();
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
try
{
string strCon = "Data Source=localhost;Initial Catalog=DB123456;Integrated Security=True";
SqlConnection myConn = new SqlConnection(strCon);
string strCom = "SELECT * FROM DB123456";
myDataSet = new DataSet();
myConn.Open();
SqlDataAdapter myCommand = new SqlDataAdapter(strCom, myConn);
myCommand.Fill(myDataSet, "DB123456");
myConn.Close();
statusStrip1.Text = "连接成功";
}
catch (Exception ex2)
{
statusStrip1.Text = "失败";
MessageBox.Show("失败:" + ex2.ToString(), "错误");
} }
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
DataSet myDataSet = new DataSet();
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
try
{
string strCon = "Data Source=localhost;Initial Catalog=DB123456;Integrated Security=True";
SqlConnection myConn = new SqlConnection(strCon);
string strCom = "SELECT * FROM DB123456";
myDataSet = new DataSet();
myConn.Open();
SqlDataAdapter myCommand = new SqlDataAdapter(strCom, myConn);
myCommand.Fill(myDataSet, "DB123456");
myConn.Close();
statusStrip1.Text = "连接成功";
}
catch (Exception ex2)
{
statusStrip1.Text = "失败";
MessageBox.Show("失败:" + ex2.ToString(), "错误");
} }
}
}
解决方案 »
- xml查询问题
- 企業管理器中的 sql server logs 是什麼日志,是怎麼看的.
- 字符串边界符的问题
- sql中text类型有效字符问题
- 散点分,大家来讨论一个优化问题,欢迎参与
- 请问SQL SERVER下那个sql.log有什么作用,请高手讲详细点?
- SQL查找兩個數據表
- 请教调用存储过程时报"从字符串向 datetime 转换时失败"的错误?
- help在Winnt上的sql server 2000数据库,在windows上用odbc建数据源可以连通,但用frontpage2000的asp页面连接时数据库时提示登录错误,不知是何原因,而同样操作在windows98下没问题。
- my sql
- 无法将 视图'dbo.BP_VIEW' 绑定到架构。'dbo.Get_needChar' 尚未绑定到架构。
- mysql中的timestamp 在sqlserver中用什么代替?
= new SqlConnection( "Server=(local);Integrated Security=SSPI;database=Pubs");SqlConnection conn
= new SqlConnection("server=(local)//NetSDK;database=pubs;Integrated Security=SSPI");SqlConnection conn = new SqlConnection(
"Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind;");SqlConnection conn = new SqlConnection(
" data source=(local);initial catalog=xr;integrated security=SSPI;
persist security info=False;workstation id=XURUI;packet size=4096; ");SqlConnection myConn = new
System.Data.SqlClient.SqlConnection("Persist Security Info=False;Integrated
Security=SSPI;database=northwind;server=mySQLServer");SqlConnection conn = new SqlConnection(
" uid=sa;pwd=passwords;initial catalog=pubs;data source=127.0.0.1;Connect Timeout=900");
http://www.connectionstrings.com/sql-server-2005