Click here to Skip to main content
15,915,094 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How I'm going to retrieved a value after i select a data in a row of data grid view ?
I'm going to retrieved the data inside the oracle database.
I'm using vb.net.
VB
Protected Sub dg1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles dg1.SelectedIndexChanged

im connectionString As String = "Data Source = ***; User ID = ***; Password = ***;"
        Dim sqlConnection As OracleClient.OracleConnection = New OracleClient.OracleConnection(connectionString)

        Dim queryString As String = "select * from abc where device = '"(dg1.Rows(1).Cells("I_NSPN95").ToString) '""

        Dim sqlCommand As OracleClient.OracleCommand = New OracleClient.OracleCommand(queryString, sqlConnection)
        sqlCommand.CommandTimeout = 0

        sqlCommand.Parameters.AddWithValue(":strDevice", OracleType.Char).Value = (dg1.Rows(1).Cells("I_NSPN95"))

        Dim dataAdapter As OracleClient.OracleDataAdapter = New OracleClient.OracleDataAdapter(sqlCommand)
        Dim dataSet As DataSet = New DataSet
        dataAdapter.Fill(dataSet)

    End Sub
End Class
Posted
Updated 26-Aug-13 17:15pm
v2
Comments
Sergey Alexandrovich Kryukov 26-Aug-13 23:22pm    
Despite the question mark, this is not a question.
Just a note: you won't get good results if your code is based on hard-coded immediate constants like "I_NSPN95", especially when you repeat them. This is totally unsupportable.
—SA
gogole_yuna 26-Aug-13 23:28pm    
ok thanks
Sergey Alexandrovich Kryukov 26-Aug-13 23:34pm    
You are welcome. So, what's the question?
—SA
gogole_yuna 27-Aug-13 2:26am    
how do i can retrieve my data by using that code ?
Sergey Alexandrovich Kryukov 27-Aug-13 10:04am    
By using that code..? Why? I thought you have problem in your code. If this is your code, you should know better how you wanted to use it... :-)
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900