你的意思看得不太明白Select * From mytable Where ..... And ....
解决方案 »
- WPF中如何重绘System.Windows.Forms.WebBrowser?
- 关于获取GridView键值,并传递给下一个页面的问题。
- C# winform serialport 正常关闭后再次开启,无法触发Datareceived事件
- 继承自WeifenLuo.WinFormsUI.Docking得窗口如何更新?
- throw new NotImplementedException();刻方法无法实现。。。。
- 微软 TTs sapi sdk5
- 求助,在线等。
- C#的反射在现实开发中哪里都用到了?
- 请问:SqlDataAdapter的Update方法可以做删除操作吗?为什么我调用的时候可以增加和修改但是不能做删除操作?
- E:\C#\新建文件夹\Convert1\Convert\Program.cs(20,21): 错误 CS0234: 命名空间“Convert”中不存在类型或命
- 如果今天老板就把你从程序员提升到项目经理,你的压力和感觉会是如何??
- C#中有无关于SNMP的类,up者有分。
"server = ; uid = ; psd = ; database = ";
string commandString =
"Select * from yourtable where... and... ";
SqlDataAdapter DataAdapter =
new SqlDataAdapter(commandString,connectiongString);
DataSet myDataSet = new DataSet();
DataAdapter.Fill(DataSet,"yourtable");
建立连接 SQLCONNECTION
建立SQL命令 SQLCOMMAND
建立数据适配器 SqlDataAdapter
执行数据适配器得到数据集。
2
使用DATAREADER来读出数据。
给你一段列程
using System;
using System.Data.SqlClient;
namespace Edoc2002.Public
{
/// <summary>
/// RspDesc 的摘要说明。
/// </summary>
public class RspDesc
{
public string State="";
public string StateDesc="";
public string DeclNo="";
public string GetDeclNo="";
public string StrRspDesc="";
private string SerialNo="";
public bool isFound=false;
private System.Data.SqlClient.SqlDataReader dataReader;
public RspDesc(string SeqNo,System.Data.SqlClient.SqlConnection conn)
{
try
{
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("SELECT DECL_NO,DECL_GET_NO,COMM_FLAG,SERIAL_NO,EDIT_COMM_FLAG FROM SEARCH_EDOC WHERE SEQ_NO='"+SeqNo+"'",conn);
dataReader = cmd.ExecuteReader();
if(dataReader.Read())
{
//有值,仅有一个
DeclNo=dataReader.GetString(0);
GetDeclNo=dataReader.GetString(1);
State = dataReader.GetString(2);
SerialNo=dataReader.GetSqlDecimal(3).ToString();
StateDesc=dataReader.GetString(4);
}
else
{
State="0001";
StrRspDesc="没有回执";
SerialNo="";
}
}
catch(Exception)
{
}
finally
{
if(dataReader!=null)
{
dataReader.Close();
dataReader=null;
}
}
if(!SerialNo.Equals(""))
{
try
{
SqlCommand RspCmd = new System.Data.SqlClient.SqlCommand("SELECT DECL_RSP_DESC_RECORD FROM DECL_RESPONSE WHERE SERIAL_NO='"+SerialNo+"'",conn);
dataReader=RspCmd.ExecuteReader();
if(dataReader.Read())
{
StrRspDesc=dataReader.GetString(0);
isFound=true;
}
}
catch(Exception)
{
}
finally
{
if(dataReader!=null)
{
dataReader.Close();
dataReader=null;
}
}
}
}
}
}