-- 1: Example of DataSet returned by the stored procedure:
C # code: Common class
Public static int SingleSTCD (DateTime StartTime, DateTime EndTime, int SMTP,
String JL, string STDCD, string STCDSTR, out DataSet ds)
{
Int ret = 0;
Ds = null;
OleDbConnection Constring = new OleDbConnection (Appraise. ConStr );
OleDbCommand cmd = new OleDbCommand ("P_Get_STCD_SingleAppraise_XunQi ",
Constring );
Try
{
OleDbDataAdapter ada = new OleDbDataAdapter ();
Cmd. CommandType = CommandType. StoredProcedure;
Cmd. Parameters. Add ("@ StartTime", OleDbType. DBTimeStamp). Value = StartTime;
Cmd. Parameters. Add ("@ EndTime", OleDbType. DBTimeStamp). Value = EndTime;
Cmd. Parameters. Add ("@ SMTP", OleDbType. Integer). Value = SMTP;
Cmd. Parameters. Add ("@ JL", OleDbType. VarChar, 50). Value = JL;
// Cmd. Parameters. Add ("@ STDCD", OleDbType. VarChar, 50). Value = STDCD;
// Evaluation criteria
Cmd. Parameters. Add ("@ STCDSTR", OleDbType. VarChar, 8000). Value = STCDSTR;
System. Data. DataSet data = new DataSet ();
Ada. SelectCommand = cmd;
Ada. Fill (data, "table ");
Ds = data;
Ret = ds. Tables [0]. Rows. Count;
If (ret =-1)
{
Return-1000; // No data
}
Else
{
Return ret;
}
}
Catch (Exception e)
{
// Database operation error, error code returned
System. Diagnostics. Debug. WriteLine (e. Message );
Return-1001;
}
Finally
{
Constring. Close ();
Cmd. Parameters. Clear ();
}
VB.net call:
Private Sub BindingDataGrid_Query ()
Dim ds As System. Data. DataSet
Zehua. Water. Appraise. SingleSTCD ("", "", 1, "III", "", "50181300,50185050, 50181350,50185100, 50185150,50185200, 50185250,
5018385,50185150, 51282300 ", ds)
DataGrid_Query.DataSource = ds
DataGrid_Query.DataBind ()
End Sub
-- 1: The stored procedure returns an array string.
REM executes the stored procedure and returns an array
Public Shared Function ExecuteSP_ToArrary (ByVal sConnString As String,
ByVal Text_STCD As String, ByVal Text_TIME As String,
ByRef TableInfo () As String)
Dim conn As OleDbConnection = New OleDbConnection (sConnString)
ReDim TableInfo (2)
Try
Conn. Open ()
Dim command As OleDbCommand = New OleDbCommand ("P_GET_QueryValue", conn)
Command. CommandType = CommandType. StoredProcedure
Dim sqlParams () As OleDbParameter = {New OleDbParameter ("@ STCD", Text_STCD ),
New OleDbParameter ("@ GETM", Text_TIME ),
New OleDbParameter ("@ ReturnValue", OleDbType. VarChar, 8000 ),
New OleDbParameter ("@ ReturnColumnCode", OleDbType. VarChar, 8000 ),
New OleDbParameter ("@ ReturnColumnName", Ole dbtype. VarChar, 8000 )}
SqlParams (2). Direction = ParameterDirection. Output
SqlParams (3). Direction = ParameterDirection. Output
SqlParams (4). Direction = ParameterDirection. Output
Dim I As Integer = 0
While I <sqlParams. Length
Command. Parameters. Add (sqlParams (I ))
I + = 1
End While
Command. ExecuteNonQuery ()
If sqlParams (2). Value. ToString (). Length> 0 Then
TableInfo (0) = sqlParams (2). Value. ToString ()
Else
End If
If sqlParams (3). Value. ToString (). Length> 0 Then
TableInfo (1) = sqlParams (3). Value. ToString ()
Else
End If
If sqlParams (4). Value. ToString (). Length> 0 Then
TableInfo (2) = sqlParams (4). Value. ToString ()
Else
End If
Catch ex As Exception
ZeHua. Log. exNoteBugs (ex, "SigleStcdEdit. aspx") sb. Append (ex. Message)
Finally
Conn. Close ()
End Try
End Function