EDN Admin
Well-known member
Hello-
Ive this piece of code:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Private <span style="color:Blue; Sub Button1_Click(<span style="color:Blue; ByVal sender <span style="color:Blue; As System.Object, <span style="color:Blue; ByVal e <span style="color:Blue; As System.EventArgs) <span style="color:Blue; Handles Button1.Click
<span style="color:Blue; Dim conn <span style="color:Blue; As <span style="color:Blue; New OracleConnection
conn.ConnectionString = <span style="color:#A31515; "User Id = APPS;Password = APPS; Data Source = PRODL"
conn.Open()
<span style="color:Blue; Dim objCmd <span style="color:Blue; As OracleCommand
<span style="color:Blue; Dim strSQL <span style="color:Blue; As <span style="color:Blue; String
<span style="color:Blue; Dim tipoAcesso <span style="color:Blue; As <span style="color:Blue; String
<span style="color:Blue; Dim da <span style="color:Blue; As <span style="color:Blue; New OracleDataAdapter(objCmd)
<span style="color:Blue; Dim ds <span style="color:Blue; As <span style="color:Blue; New DataSet
<span style="color:Blue; If conn.State = ConnectionState.Open <span style="color:Blue; Then
<span style="color:Blue; With objCmd
.Parameters.Add(<span style="color:Blue; New OracleParameter(<span style="color:#A31515; "P1", OracleDbType.Varchar2).Value = <span style="color:Blue; Me.TextBox1.Text)
strSQL = <span style="color:#A31515; "SELECT user_name FROM UTLT_USERS WHERE user_id = 1"
<span style="color:Blue; End <span style="color:Blue; With
<span style="color:Blue; Else
MsgBox(<span style="color:#A31515; "Problema na ligação a Oracle", vbOKOnly)
<span style="color:Blue; End <span style="color:Blue; If
objCmd.ExecuteNonQuery()
da.Fill(ds)
<span style="color:Blue; Dim linhas = ds.Tables(0).Rows.<span style="color:Blue; Count
<span style="color:Blue; If linhas = 1 <span style="color:Blue; Then
tipoAcesso = ds.Tables(0).Rows(0).Item(3)
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; End <span style="color:Blue; Sub
<span style="color:Blue; End <span style="color:Blue; Class
[/code]
On the line:
.Parameters.Add(New OracleParameter("P1", OracleDbType.Varchar2).Value = Me.TextBox1.Text)
Im getting the error: "Object reference not set to an instance of an object."
According to the documentation i read the syntax is correct. What can i be doing wrong?
Thanks in advance for any kind help
Octavio
View the full article
Ive this piece of code:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Private <span style="color:Blue; Sub Button1_Click(<span style="color:Blue; ByVal sender <span style="color:Blue; As System.Object, <span style="color:Blue; ByVal e <span style="color:Blue; As System.EventArgs) <span style="color:Blue; Handles Button1.Click
<span style="color:Blue; Dim conn <span style="color:Blue; As <span style="color:Blue; New OracleConnection
conn.ConnectionString = <span style="color:#A31515; "User Id = APPS;Password = APPS; Data Source = PRODL"
conn.Open()
<span style="color:Blue; Dim objCmd <span style="color:Blue; As OracleCommand
<span style="color:Blue; Dim strSQL <span style="color:Blue; As <span style="color:Blue; String
<span style="color:Blue; Dim tipoAcesso <span style="color:Blue; As <span style="color:Blue; String
<span style="color:Blue; Dim da <span style="color:Blue; As <span style="color:Blue; New OracleDataAdapter(objCmd)
<span style="color:Blue; Dim ds <span style="color:Blue; As <span style="color:Blue; New DataSet
<span style="color:Blue; If conn.State = ConnectionState.Open <span style="color:Blue; Then
<span style="color:Blue; With objCmd
.Parameters.Add(<span style="color:Blue; New OracleParameter(<span style="color:#A31515; "P1", OracleDbType.Varchar2).Value = <span style="color:Blue; Me.TextBox1.Text)
strSQL = <span style="color:#A31515; "SELECT user_name FROM UTLT_USERS WHERE user_id = 1"
<span style="color:Blue; End <span style="color:Blue; With
<span style="color:Blue; Else
MsgBox(<span style="color:#A31515; "Problema na ligação a Oracle", vbOKOnly)
<span style="color:Blue; End <span style="color:Blue; If
objCmd.ExecuteNonQuery()
da.Fill(ds)
<span style="color:Blue; Dim linhas = ds.Tables(0).Rows.<span style="color:Blue; Count
<span style="color:Blue; If linhas = 1 <span style="color:Blue; Then
tipoAcesso = ds.Tables(0).Rows(0).Item(3)
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; End <span style="color:Blue; Sub
<span style="color:Blue; End <span style="color:Blue; Class
[/code]
On the line:
.Parameters.Add(New OracleParameter("P1", OracleDbType.Varchar2).Value = Me.TextBox1.Text)
Im getting the error: "Object reference not set to an instance of an object."
According to the documentation i read the syntax is correct. What can i be doing wrong?
Thanks in advance for any kind help
Octavio
View the full article