I try to show my table data type in datagridview vb.net. Here is the sample code :
oradb = "Data Source=(DESCRIPTION=" _
+ "(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" & txtServer1.Text & ")(PORT=" & port1.Value & ")))" _
+ "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" & txtSID.Text & ")));" _
+ "User Id=" & txtUsername1.Text & ";" _
+ "Password=" & txtPassword1.Text
Dim connOracle As New OracleConnection(oradb)
Try
connOracle.Open()
connOracle.Close()
Catch ex As Exception
MessageBox.Show(ex.Message.ToString())
Finally
End Try
SQL = "desc hr.employees"
myCommand1.Connection = connOracle
myCommand1.CommandText = SQL
myAdapter1.SelectCommand = myCommand1
myAdapter1.Fill(myTablePreview)
DataGridView1.DataSource = myTablePreview
I try login using username “system”. When I run this code, I got error message “ORA-00900: invalid SQL statement”
is there any wrong with my query??
pls helpme. thank’s…..
DESC (DESCRIBE) is a SQL*Plus command, not a SQL verb. SQL*Plus is a front-end tool for SQL, so it adds some commands of its own, and this is one of those. You have to stick with SQL when using OLE DB.
If you want this data in a client program, you might want to try something like:
or like this:
This is pure (Oracle) SQL, which you can experiment with in SQL*Plus until you get the set of columns that you need.
Devian Yudha,