vb.net 如何使oracle语句带参数 5
objPara = New Oracle.DataAccess.Client.OracleParameter
objPara.ParameterName = "name"
objPara.OracleDbType = Oracle.DataAccess.Client.OracleDbType.Varchar2
objPara.Direction = ParameterDirection.Input
objPara.Value = CInt(Me.txtName.Text.Trim)
objListSec.Add(objPara)
objPara = New Oracle.DataAccess.Client.OracleParameter
objPara.ParameterName = "password"
objPara.OracleDbType = Oracle.DataAccess.Client.OracleDbType.Varchar2
objPara.Direction = ParameterDirection.Input
objPara.Value = CInt(Me.txtPassword.Text.Trim)
objList.Add(objPara)
我这么写对吗 我一运行ExecuteNonQuery哪里为什么报错? 展开
2016-03-14 · 百度知道合伙人官方认证企业
oracle语句带参数查询在vb.net中的应用。
1、创建数据库连接:
Dim myConnection As OleDbConnection
Dim myOracleDataAdapter As OleDbDataAdapter
myConnection = New OleDbConnection("Provider=OraOLEDB.Oracle.1;Data _
Source=OraDb_192.168.1.148;user id=scott;password=tiger")
myOracleDataAdapter = New OleDbDataAdapter("select * from user_tables", myConnection)
Dim myDataSet As DataSet = New DataSet()
Dim myDataRow As DataRow
myOracleDataAdapter.Fill(myDataSet, "user_tables")
Console.WriteLine(myDataSet.Tables("dept").Rows(0)(0))
Console.WriteLine(myDataSet.Tables("user_tables").Columns(0).ColumnName)
Console.ReadLine();
2、如果用户按照上面所示输入 CLERK,则数据库接收的命令文本如下:
select count(ename) from emp where job = 'CLERK'
执行结果如下:
cmd.CommandText = "select count(ename) from emp where " _
+ "job = '" + TextBox1.Text + "'" ' VB.NET