16,554
社区成员
发帖
与我相关
我的任务
分享
Dim myds As New DataSet '定义数据集
If myCon.State = ConnectionState.Closed Then myCon.Open()
myCmd.CommandText = SqlString
myCmd.Connection = myCon
myCmd.ExecuteNonQuery()
myds.Clear()
MyDa.SelectCommand = myCmd '执行命令给数据适匹器
MyDa.Fill(myds) '填充数据集
Dim c As Integer
c = myds.Tables(0).Rows.Count
'保存图片
Dim ms As New MemoryStream
Me.PictureBox1.Image.Save(ms, Me.PictureBox1.Image.RawFormat)
Dim arrayImage() As Byte = ms.GetBuffer
ms.Close()
If myCon.State = ConnectionState.Closed Then myCon.Open()
txtSQL = "UPDATE JSSty SET Images = @IMAGES WHERE (CODE = N'" & Me.LabCode.Text.Trim & "')"
myCmd.CommandText = txtSQL
myCmd.Connection = myCon
myCmd.Parameters.Clear()
myCmd.Parameters.Add(New SqlParameter("@IMAGES", SqlDbType.Image)).Value = arrayImage
myCmd.ExecuteNonQuery()
myCon.Close()
protected void Page_Load(object sender, EventArgs e)
{
//实例化Connection对象
SqlConnection connection = new SqlConnection("Data Source=(local);Initial Catalog=AspNetStudy;Persist Security Info=True;User ID=sa;Password=sa");
//实例化Command对象
SqlCommand command = new SqlCommand("select count(1) as 男性人数 from UserInfo where sex=1", connection);
//打开Connection对象
connection.Open();
//执行SQL语句
int count = int.Parse(command.ExecuteScalar().ToString()); //用于获取表中符合条件的记录总数
//关闭Connection对象
connection.Close();
Response.Write("在UserInfo表里共有" + count + "个男性。");
}