您好,登錄后才能下訂單哦!
本篇文章給大家分享的是有關VB.NET中怎么調用存儲過程,小編覺得挺實用的,因此分享給大家學習,希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。
八種常用VB.NET語法詳解
VB.NET事件通道使用技巧須知
實際操作VB.NET啟動外部程序技巧講解
迅速實現VB.NET圖像操作方法簡介
VB.NET多窗體實際編寫方式講解
VB.NET調用存儲過程返回DataSet 的例子:
C# 代碼 :通用類
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 ;
//評價標準
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; //無數據
}
else
{
return ret;
}
}
catch(Exception e)
{
//數據庫操作發生錯誤,返回錯誤代碼
System.Diagnostics.Debug.
WriteLine(e.Message);
return -1001;
}
finally
{
Constring.Close();
cmd.Parameters.Clear();
}
VB.NET調用存儲過程:
Private Sub BindingDataGrid_Query()
Dim ds As System.Data.DataSet
Zehua.Water.Appraise.SingleSTCD
("1999-5-1", "1999-9-1", 1, "Ⅲ", "",
"50181300,50185050,50181350,50185100,
50185150,50185200,50185250,50181200,
50185150,51282300", ds)DataGrid_Query.DataSource = ds
DataGrid_Query.DataBind()
End Sub
VB.NET調用存儲過程返回數組字符串
REM 執行存儲過程,返回一數組
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.
StoredProcedureDim 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", OleDbType.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
以上就是VB.NET中怎么調用存儲過程,小編相信有部分知識點可能是我們日常工作會見到或用到的。希望你能通過這篇文章學到更多知識。更多詳情敬請關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。