VB.net做一个小程序 求教 75

请大神帮我看看问题出在哪里?另外我如果要加Button1点击执行结果输出在DataGridView1中应该怎么写?谢谢了,小白求教!~PrivateSubForm1_Lo... 请大神帮我看看问题出在哪里?另外我如果要加Button1点击执行结果输出在DataGridView1中 应该怎么写?谢谢了,小白求教!~ Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim oleDbConnection1 As OleDb.OleDbConnection Dim oledbDataAdapter As OleDb.OleDbDataAdapter Dim oledbData As DataSet = New DataSet Dim strConnect As String = "Provider= OraOLEDB.Oracle;Data Source=888;User ID=888;Password=888;" oleDbConnection1 = New System.Data.OleDb.OleDbConnection(strConnect) Dim strSql As String strSql = "select *" & " from xx" Dim oledbCommand As OleDb.OleDbCommand oledbCommand.CommandText = strSql oledbCommand.CommandType = CommandType.Text oledbCommand.Connection = oleDbConnection1 oledbDataAdapter.SelectCommand = oledbCommand oleDbConnection1.Open() oledbDataAdapter.Fill(oledbData, "gy_bingrenxx") oleDbConnection1.Close() End Sub 展开
 我来答
syx54
2017-07-26 · TA获得超过7378个赞
知道大有可为答主
回答量:6567
采纳率:83%
帮助的人:2738万
展开全部
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim oleDbConnection1 As OleDb.OleDbConnection
Dim oledbDataAdapter As OleDb.OleDbDataAdapter
Dim oledbData As DataSet = New DataSet
Dim strConnect As String = "Provider= OraOLEDB.Oracle;Data Source=888;User ID=888;Password=888;"
oleDbConnection1 = New System.Data.OleDb.OleDbConnection(strConnect)
Dim strSql As String
strSql = "select *" & " from xx"
Dim oledbCommand As OleDb.OleDbCommand
oledbCommand.CommandText = strSql
oledbCommand.CommandType = CommandType.Text
oledbCommand.Connection = oleDbConnection1
oledbDataAdapter.SelectCommand = oledbCommand
oleDbConnection1.Open()
oledbDataAdapter.Fill(oledbData, "gy_bingrenxx")
oleDbConnection1.Close()

'在窗体上添加一个DataGridView控件,在这个位置加一句代码
DataGridView1.DataSource = oledbDataAdapter.Tables("gy_bingrenxx")

End Sub
更多追问追答
追问

我调试了下但是还是报错

追答
你先按照我说的,直接放在  Form1_Load()事件里,可以看到结果吗?
你那样不行的!
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式