Analytics

2010年8月12日 星期四

[VB.NET]使用 SqlParameter 接收由DB取出的參數值(Use SqlParameter received parameter values extracted from the DB)


問題
使用 SqlParameter 接收由DB取出的參數值



解決方法
 Dim con As SqlConnection = ""
 con.Open()
 Dim com As SqlCommand = New SqlCommand()
 com.Connection = con                               
 com.CommandType = CommandType.StoredProcedure
  com.CommandText = "MY_PROC"
 com.Parameters.Add("NAME", SqlDbType.VarChar, 100).Value = "王曉明"
 Dim mResult As SqlParameter = com.Parameters.Add("ID", SqlDbType.VarChar, 10)
 mResult.Direction = ParameterDirection.Output
 com.ExecuteNonQuery()
  If com.Parameters("ID").Value <> "" Then
                                     
  End If
con.Close()

沒有留言:

熱門文章