用command对象,结果给datareader,在调用getstring(0)SqlConnection myconn=new SqlConnection("...");
myconn.Open();
SqlCommand mycommand=new SqlCommand(sql,myconn);
SqlDataReader myreader=mycommand.ExecuteReader();
while (myreader.Read())
{
text1.text=myreader.GetString(0);
}
myreader.Close();
myconn.Close();
myconn.Open();
SqlCommand mycommand=new SqlCommand(sql,myconn);
SqlDataReader myreader=mycommand.ExecuteReader();
while (myreader.Read())
{
text1.text=myreader.GetString(0);
}
myreader.Close();
myconn.Close();
改写成select sum(score) as one,count(*) as two from tables1 where field=1然后在把ONE当作字段来访问.
OleDbCommand cmd=new OleDbCommand(sql,conn);
TextBox1.Text=(string)cmd.ExecuteScalar();
执行了sql后,我该怎么把它给text?
m_contentSQL = "select sum(gjsl) as zh from " & Session("ywnameid1") & " where " & Session("bcxid")
m_objdscommand = New OleDbDataAdapter(m_contentSQL, "Provider=MSDAORA.1;Password=swpi;User ID=toollib;Data Source=connect_toollib")
m_objdscommand.Fill(m_objdataset, "appd_tabs") m_objtable = m_objdataset.Tables("appd_tabs")
myview = m_objtable.DefaultView TextBox1.Text = ??(这个地方怎么写?)
TextBox1.DataBind()
TextBox1.Text=((TextBox)m_objtable.DefaultView[0]).Text
TextBox1.DataBind()
可将以上两句改为
TextBox1.DataBind("Text",m_objdataset,appd_tabs.zh)
因为DataBind有三个参数可选。