I use Sybase 15 as a backend database. I got a new machine and installed Visual Studio. I copied an application from my old machine to the new machine. I started getting a vierd proble. When I use a Command object to fetch data from a table and the CommandType
is Text (i.e. CommandType.Text) it hangs when I execute the Command.ExecuteScalar, or Command.ExecuteReader. BUT if I use CommandType.StoredProcedure it works fine.
Dim liCANID As Integer
Dim lsSQL As String = "SELECT CANID FROM ptCAN WHERE DefaultCAN = 1"
' ***** IT HANGS IF I USE THE FOLLOWING TWO LINES *****
Dim cmdDefaultCAN As New System.Data.OleDb.OleDbCommand(lsSQL, ptConnection)
cmdDefaultCAN.CommandType = CommandType.Text
' ***** IT WORKS FINE IF I USE THE FOLLOWING TWO LINES *****
'Dim cmdDefaultCAN As New System.Data.OleDb.OleDbCommand("ptSpGetDefaultCANID", ptConnection)
'cmdDefaultCAN.CommandType = CommandType.StoredProcedure
Try
ptConnection.open()
liCANID = cmdDefaultCAN.ExecuteScalar() ' ***** IT HANGS HERE *****
Catch ex As Exception
liCANID = Nothing
Finally
ptConnection.close()
End Try
Are you using the correct provider here? Not sure if OleDb is compatible with Sybase. Without knowing anything about Sybase, I just found through googling that there's a dedicated provider for Sybase (Sybase.Data.AseClient). Maybe this can help you?
OleDb is compatible with Sybase. I have been using it for many years. It works ok when CommandType=StoredProcedure. It hands only when CommandType=Text. It is very strange.
kirit_raja
Member
61 Points
47 Posts
Problem with fetching data from a database table
Sep 26, 2007 08:28 PM|LINK
Hi All,
I use Sybase 15 as a backend database. I got a new machine and installed Visual Studio. I copied an application from my old machine to the new machine. I started getting a vierd proble. When I use a Command object to fetch data from a table and the CommandType is Text (i.e. CommandType.Text) it hangs when I execute the Command.ExecuteScalar, or Command.ExecuteReader. BUT if I use CommandType.StoredProcedure it works fine.
Here is a sample code:
**********************************************************************************************
Dim liCANID As Integer
Dim lsSQL As String = "SELECT CANID FROM ptCAN WHERE DefaultCAN = 1"
' ***** IT HANGS IF I USE THE FOLLOWING TWO LINES *****
Dim cmdDefaultCAN As New System.Data.OleDb.OleDbCommand(lsSQL, ptConnection)
cmdDefaultCAN.CommandType = CommandType.Text
' ***** IT WORKS FINE IF I USE THE FOLLOWING TWO LINES *****
'Dim cmdDefaultCAN As New System.Data.OleDb.OleDbCommand("ptSpGetDefaultCANID", ptConnection)
'cmdDefaultCAN.CommandType = CommandType.StoredProcedure
Try
ptConnection.open()
liCANID = cmdDefaultCAN.ExecuteScalar() ' ***** IT HANGS HERE *****
Catch ex As Exception
liCANID = Nothing
Finally
ptConnection.close()
End Try
**********************************************************************************************
Can somebody help me with this problem? Thank you
johram
All-Star
28531 Points
3567 Posts
Re: Problem with fetching data from a database table
Sep 27, 2007 09:05 PM|LINK
Are you using the correct provider here? Not sure if OleDb is compatible with Sybase. Without knowing anything about Sybase, I just found through googling that there's a dedicated provider for Sybase (Sybase.Data.AseClient). Maybe this can help you?
http://www.carlprothman.net/Default.aspx?tabid=86#AseClientManagedProvider
kirit_raja
Member
61 Points
47 Posts
Re: Problem with fetching data from a database table
Oct 01, 2007 02:14 PM|LINK
Thank you for your response.
OleDb is compatible with Sybase. I have been using it for many years. It works ok when CommandType=StoredProcedure. It hands only when CommandType=Text. It is very strange.
kirit_raja
Member
61 Points
47 Posts
Re: Problem with fetching data from a database table
Oct 03, 2007 02:30 PM|LINK
Hello all,
I am still trying for a solution to this. Please help.
Thank you,
kirit_raja
Member
61 Points
47 Posts
Re: Problem with fetching data from a database table
Oct 15, 2007 02:34 PM|LINK
Please help.