呵呵,看样子你应该是想显示的一行是特定的一行吧
让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:国际域名空间、网站空间、营销软件、网站建设、蒙城网站维护、网站推广。
你看这样行不行
你用rs接受到存储过程返回的表后
直接给rs设置一个过滤条件,例如 rs.Filter="ID=1"
将你要的那条记录过滤出来后再将rs绑定到DataGridView
希望能帮到你……
我提供下c#里实现的方法:
SqlConnection conn="连接数据库语句";
SqlCommand cmd=new SqlCommand("存储过程名 A或B",conn);
cmd.CommandType=CommandType.StoredProcedure; //这句表示cmd的字符串是存储过程
cmd.Parameters.Add("@存储过程里的参数,用@开头",SqlDbType.Nvarchar).Value="参数值";
...如果还有参数,继续上句
conn.Open();
cmd.ExecuteNonQuery();
如果不要参数,直接把cmd.Parameters这句去掉。SqlDbType表示参数的类型,自己选择
其实还是ADO.NET常用对象的基础用法知识;可以自己阅读MSDN文档来了解这方面的入门知识。for example:--------------------------CREATE PROCEDURE [AddNewInvoiceInfo] (@sUserID int,@sClaimMethod varchar(50),@sInvoiceNum varchar(50),@sInvoiceDate datetime,@sBuyCity varchar(50))AS Insert Into SMB_InvoiceInfo (MemberID,ClaimMethod,InvoiceNum,InvoiceDate,InvoiceCity) Values (@sUserID,@sClaimMethod,@sInvoiceNum,@sInvoiceDate,@sBuyCity) return @@IDENTITY GO ---------------------------------------------Dim CN As New SqlConnection() Dim InvoiceID As String Try CN.ConnectionString = DBConStr CN.Open() Dim CMD As SqlCommand CMD = New SqlCommand("AddNewInvoiceInfo", CN) CMD.CommandType = CommandType.StoredProcedure CMD.Parameters.Add(New SqlParameter("@sUserID", SqlDbType.Int)) CMD.Parameters("@sUserID").Value = CInt(UserID.Text) CMD.Parameters.Add(New SqlParameter("@sClaimMethod", SqlDbType.VarChar, 50)) CMD.Parameters("@sClaimMethod").Value = TransName.Text CMD.Parameters.Add(New SqlParameter("@sInvoiceNum", SqlDbType.VarChar, 50)) CMD.Parameters("@sInvoiceNum").Value = InvoiceNum.Text CMD.Parameters.Add(New SqlParameter("@sInvoiceDate", SqlDbType.DateTime)) CMD.Parameters("@sInvoiceDate").Value = InvoiceDate.SelectedDate.Date CMD.Parameters.Add(New SqlParameter("@sBuyCity", SqlDbType.VarChar, 50)) CMD.Parameters("@sBuyCity").Value = BuyCity.Text CMD.Parameters.Add(New SqlParameter("@sInvoiceID", SqlDbType.Int)) CMD.Parameters("@sInvoiceID").Direction = ParameterDirection.ReturnValue CMD.ExecuteNonQuery() InvoiceID = CMD.Parameters("@sInvoiceID").Value.ToString() CMD.Dispose() Catch ex As Exception Response.Write(ex.ToString()) Finally CN.Close() End Try
//存储过程代码
CREATE PROCEDURE [AddNewInvoiceInfo] (@sUserID int,@sClaimMethod varchar(50),@sInvoiceNum varchar(50),@sInvoiceDate datetime,@sBuyCity varchar(50))AS
Insert Into SMB_InvoiceInfo (MemberID,ClaimMethod,InvoiceNum,InvoiceDate,InvoiceCity) Values (@sUserID,@sClaimMethod,@sInvoiceNum,@sInvoiceDate,@sBuyCity)
return @@IDENTITY
GO
//调用存储过程代码
Dim CN As New SqlConnection()
Dim InvoiceID As String
Try
CN.ConnectionString = DBConStr
CN.Open()
Dim CMD As SqlCommand
CMD = New SqlCommand(AddNewInvoiceInfo, CN)
CMD.CommandType = CommandType.StoredProcedure
CMD.Parameters.Add(New SqlParameter(@sUserID, SqlDbType.Int))
CMD.Parameters(@sUserID).Value = CInt(UserID.Text)
CMD.Parameters.Add(New SqlParameter(@sClaimMethod, SqlDbType.VarChar, 50))
CMD.Parameters(@sClaimMethod).Value = TransName.Text
CMD.Parameters.Add(New SqlParameter(@sInvoiceNum, SqlDbType.VarChar, 50))
CMD.Parameters(@sInvoiceNum).Value = InvoiceNum.Text
CMD.Parameters.Add(New SqlParameter(@sInvoiceDate, SqlDbType.DateTime))
CMD.Parameters(@sInvoiceDate).Value = InvoiceDate.SelectedDate.Date
CMD.Parameters.Add(New SqlParameter(@sBuyCity, SqlDbType.VarChar, 50))
CMD.Parameters(@sBuyCity).Value = BuyCity.Text
CMD.Parameters.Add(New SqlParameter(@sInvoiceID, SqlDbType.Int))
CMD.Parameters(@sInvoiceID).Direction = ParameterDirection.ReturnValue
CMD.ExecuteNonQuery()
InvoiceID = CMD.Parameters(@sInvoiceID).Value.ToString()
CMD.Dispose()
Catch ex As Exception
Response.Write(ex.ToString())
Finally
CN.Close()
End Try