Link to home
Start Free TrialLog in
Avatar of ashish2k
ashish2k

asked on

Sybase connection string with ASP.net

Hi
I am not able to connect to Sybase Adaptive Server Enterprise 12.0 using ASP.net . I have done it through ASP but through ASP.net.
Can any body send me the code for connecting
Sybase Adaptive Server Enterprise 12.0 using ASP.net

Thank You
Bye
Avatar of amitpagarwal
amitpagarwal
Flag of India image

All you need to do is set up the appropriate Data Source through the Administration tools and use the code below to access your tables.

try
 {
  // create a new ADOConnection to the text file through ODBC and an existing Data Source
   ADOConnection conn = new ADOConnection("Provider=MSDASQL;DSN=registrations;");
  //  create a DataSet Command that selects all the records from the registration.txt table (which in this case is a file)
   ADODataSetCommand AdoCmd = new ADODataSetCommand("SELECT * FROM registrations.txt", conn);

  // fill the dataset with the registration.txt table
   AdoCmd.FillDataSet(dataSet1, "registrations.txt");
   DataTable ContactTable = dataSet1.Tables[0];
   int count = 0;

  // loop through each row of the table and fill 15 rows of the listview
   foreach (DataRow dr in ContactTable.Rows)
   {
     listView3.ListItems[count].Text = dr["LastName"].ToString();
     listView3.ListItems[count].SetSubItem(0, dr["FirstName"].ToString());
     listView3.ListItems[count].SetSubItem(1, dr["Company"].ToString());
     listView3.ListItems[count].SetSubItem(2, dr["Address"].ToString());
     count++;
     if (count > 15)
      {
        break;
      }
    }
 }
catch(ADOException ae)
 {
   Console.WriteLine(ae.Message.ToString());
 }
Avatar of ashish2k
ashish2k

ASKER

Hi
I want the coding with OleDb in ASP.net
Actually all my project will further depend on that,
that's why I don't want to use ADOConnection I would like to do it with OleDb in ASP.net.
Can you give me in that.
Bye
Hi there.

The following steps should be taken:

1) Use SYBASE\OLEDB\sydaadm.exe utility to setup your datasource.

2) The connection string will look like the following:

my_OleDbConnection.ConnectionString =
"Provider=Sybase.ASEOLEDBProvider.2;Initial Catalog=MY_DATABSE;Password=MY_PASSWORD;User ID=USER_ID;Data Source=DATASOURCE_NAME;Server Name=MY_SERVER;Network Protocol=Winsock;Server Port Address=5000;Optimize Prepare=Partial;Select Method=Direct;Raise Error Behavior=MS Compatible;Print Statement Behavior=MS Compatible;Extended ErrorInfo=FALSE;Stored Proc Row Count=Last Statement Only;Row Cache Size=50;Enable Quoted Identifiers=0;Packet Size=1;Default Length For Long Data=1024"
Guys,
Excuse my ignorance, but I've been developing ASP/Sybase apps for a while now, and now we're migrating everything over to .Net, can anyone give me a sample aspx page of connecting Sybase to my datagrid ??

Thanks in advance.
-Joseph-
Guys,
Excuse my ignorance, but I've been developing ASP/Sybase apps for a while now, and now we're migrating everything over to .Net, can anyone give me a sample aspx page of connecting Sybase to my datagrid ??

Thanks in advance.
-Joseph-
Guys,
Excuse my ignorance, but I've been developing ASP/Sybase apps for a while now, and now we're migrating everything over to .Net, can anyone give me a sample aspx page of connecting Sybase to my datagrid ??

Thanks in advance.
-Joseph-
Dear: oxinfo

I've rejected your proposed answer as Experts Exchange holds an experiment to work without the answer button.

See:        https://www.experts-exchange.com/jsp/communityNews.jsp
Paragraph: Site Update for Wednesday, November 06, 2002

By this rejection the Asker will be notified by mail and hopefully he will take his responsibility to finalize the question or post an additional comment.
The Asker sees a button beside every post which says "Accept This Comment As Answer" (including rejected answers) -- so if he/she thinks yours is the best, you'll be awarded the points and the grade.

Thanks !

modulo

Community Support Moderator
Experts Exchange
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

PAQ/No Refund

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

ChrisKing
EE Cleanup Volunteer
ASKER CERTIFIED SOLUTION
Avatar of modulo
modulo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial