"CommandText property has not been initialized" error

Experiences, small talk, and other automation gossip.
vivek.guvva
Posts: 31
Joined: Mon Feb 22, 2016 7:21 pm

"CommandText property has not been initialized" error

Post by vivek.guvva » Wed Apr 06, 2016 5:47 pm

Hi, I am passing sql query as a parameter to the function. When i try to execute the code, it is throwing me error "ExecuteReader: CommandText property has not been initialized"

It works fine when i put SQl query in the code and execute. The problem is when I am passing that query as parameter using excel data connector. Below is the code that i have used. Please let me know where might be the issue.


Public Shared Sub TestConnection(query as String)

Dim digitalTracksDT As System.Data.DataTable
Dim conn As New OdbcConnection("DSN=Database_Name")
conn.Open()
System.Console.WriteLine("Database Connection opened ")
Dim digitalTrackGet As New OdbcCommand(query, conn)
Dim adp3 As New OdbcDataAdapter(digitalTrackGet)
adp3.Fill(digitalTracksDT)
System.Console.WriteLine("Data Table filled successfully")

conn.Close()

End Sub

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: "CommandText property has not been initialized" error

Post by odklizec » Thu Apr 07, 2016 7:46 am

Hi,

Is this problem somehow related to another your post?...
http://www.ranorex.com/forum/pass-param ... t9236.html
Have you debugged the code? Is the 'query' variable actually filled with something?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

vivek.guvva
Posts: 31
Joined: Mon Feb 22, 2016 7:21 pm

Re: "CommandText property has not been initialized" error

Post by vivek.guvva » Thu Apr 07, 2016 12:55 pm

Hi,
I think this another issue when code is executed from recorder. I am getting this error when I am executing the code module from recorder even thought the parameter values are defined in the code itself.

User avatar
RobinHood42
Posts: 324
Joined: Fri Jan 09, 2015 3:24 pm

Re: "CommandText property has not been initialized" error

Post by RobinHood42 » Fri Apr 08, 2016 1:24 pm

Hi,

take a look at the following thread:

https://social.msdn.microsoft.com/Forum ... aproviders

I aggree totally with Pavel, you should use the debugger in order to analyze your code.

Cheers,
Robin