string Conn="server=.;database=Test;Integrated Security=SSPI";
???SqlConnection con=new SqlConnection(Conn);
???con.Open();
???this.Label1.Text=con.State.ToString();
???con.Close();
------------------------------------------------------------------------------------------------------
下面這段代碼是返回特定的ID號的:)
???SqlConnection con=new SqlConnection(Conn);
???con.Open();
???this.Label1.Text=con.State.ToString();
???con.Close();
------------------------------------------------------------------------------------------------------
下面這段代碼是返回特定的ID號的:)
string Conn="server=.;database=Test;Integrated Security=SSPI";
???SqlConnection con=new SqlConnection(Conn);
???con.Open();
???SqlCommand cmd=new SqlCommand("select UserID from Test where UserName='yinxing'",con);
???int d=(int)cmd.ExecuteScalar();
???this.Label1.Text="yinxing 的ID號是:"+d.ToString();
???con.Close();
???SqlConnection con=new SqlConnection(Conn);
???con.Open();
???SqlCommand cmd=new SqlCommand("select UserID from Test where UserName='yinxing'",con);
???int d=(int)cmd.ExecuteScalar();
???this.Label1.Text="yinxing 的ID號是:"+d.ToString();
???con.Close();