[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

(Rachel Reese)

12/25/2002 8:52:00 PM

Hi folks,

I'm connecting to sybase via ODBC. I've created the DSN, and tested
it with "Query Tool (using ODBC)". It connects without a problem.
When I try to simply connect and bind to a datagrid, I get a "server
not found" error.

Here's my code-behind:

-----------------------------------------------------------
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents MyDataGrid As
System.Web.UI.WebControls.DataGrid
Protected WithEvents Outputvar As
System.Web.UI.WebControls.Literal

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form
Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region
Dim strConn As String = "Driver={Sybase System
11};srvr=MY_SERVER;UID=user;PWD=password;Database=DATABASE"
Dim strSQL As String = "select * from codes"
Dim Conn As New OdbcConnection(strConn)

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Conn.Open()
Dim da As New OdbcDataAdapter(strSQL, Conn)
Dim ds As New DataSet("Codes")
da.Fill(ds)
MyDataGrid.DataSource = ds
MyDataGrid.DataBind()
Conn.Close()

End Sub

End Class
-----------------------------------------------------------

I've tried adding the dsn and taking out the server and database
attributes... all to no avail.

Anyone have any ideas why this isn't working?

On another note, does anyone have any experience with the Datadirect
Sybase to .NET Connection Tool? Any comments?

-Rachel
1 Answer

Mike Helbert

12/2/2002 6:07:00 PM

0

Rachel,

I've been doing most of my Sybase work with the OLE DB
driver, but just had occasion to try the ODBC. Once I
created the DSN, all I had to do for the connection string
was "DSN=test3;UID=user;PWD=password". I am using client
version 12.5.

Hadn't heard of the Sybase to .NET connection tool. Sounds
interesting.

HTH,
Mike Helbert

>-----Original Message-----
>Hi folks,
>
>I'm connecting to sybase via ODBC. I've created the DSN,
and tested
>it with "Query Tool (using ODBC)". It connects without a
problem.
>When I try to simply connect and bind to a datagrid, I
get a "server
>not found" error.
>
>Here's my code-behind:
>
>----------------------------------------------------------
-
>Public Class WebForm1
> Inherits System.Web.UI.Page
> Protected WithEvents MyDataGrid As
>System.Web.UI.WebControls.DataGrid
> Protected WithEvents Outputvar As
>System.Web.UI.WebControls.Literal
>
>#Region " Web Form Designer Generated Code "
>
> 'This call is required by the Web Form Designer.
> <System.Diagnostics.DebuggerStepThrough()> Private Sub
>InitializeComponent()
>
> End Sub
>
> Private Sub Page_Init(ByVal sender As System.Object,
ByVal e As
>System.EventArgs) Handles MyBase.Init
> 'CODEGEN: This method call is required by the Web
Form
>Designer
> 'Do not modify it using the code editor.
> InitializeComponent()
> End Sub
>
>#End Region
> Dim strConn As String = "Driver={Sybase System
>11};srvr=MY_SERVER;UID=user;PWD=password;Database=DATABASE
"
> Dim strSQL As String = "select * from codes"
> Dim Conn As New OdbcConnection(strConn)
>
> Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As
>System.EventArgs) Handles MyBase.Load
> Conn.Open()
> Dim da As New OdbcDataAdapter(strSQL, Conn)
> Dim ds As New DataSet("Codes")
> da.Fill(ds)
> MyDataGrid.DataSource = ds
> MyDataGrid.DataBind()
> Conn.Close()
>
> End Sub
>
>End Class
>----------------------------------------------------------
-
>
>I've tried adding the dsn and taking out the server and
database
>attributes... all to no avail.
>
>Anyone have any ideas why this isn't working?
>
>On another note, does anyone have any experience with the
Datadirect
>Sybase to .NET Connection Tool? Any comments?
>
>-Rachel
>.
>