AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
 Dynamic Paging For DataList Control with PagedDataSource
Posted by Charlie Childs on  4/7/2010 11:41:57 AM Category: ADO.NET
Add to my favorites
Email to friend
I have been looking for a solution to page a datalist and was very pleased to find
http://www.aspdotnetcodes.com/DataList_Dynamic_Paging_PagedDataSource.aspx because the results demonstrated look brilliant.

I got an exception at quite an early stage in the tutorial but persevered to the end of the lesson in the hope that I would find a solution to the exception. Unfortunately I cannot so i would be very grateful if anyone can help.

The tutorial uses a Country database but I use my own training database. Aside from that I have all the code from the tutorial placed in my pages and there are no squiggly lines.

My error comes from line 4 of the below extract from the code behind in default.aspx.cs.

1 private void BindGrid()
2 {
3 string sql = "SELECT [Title] FROM [TableSG1] ORDER BY [Title] DESC";
4 SqlDataAdapter da = new SqlDataAdapter(sql,"ConnectionStrings:ConnectionString");
5 DataTable dt = new DataTable();
6 da.Fill(dt);

The exception is "Format of the initialization string does not conform to specification starting at index 0"

I copied my connection string from the default.aspx page after adding the datasource.
(In the tutorial there was nothing said about adding the datasource but I decided that having the datasource was probable one of those things that goes without saying because it produced a connection string).
I have tried using the connection string from the webconfig file but squiggly lines told me to forget that idea.

I have searched online and have tried various possible remedies used for other similar problems but I do not have the experience to truly understand how to proceed.

I have the pager stting on my disign page as it should be and think it is ready to use apart from this line of code not working and preventing debug.

Please help

Post Your Reply Post New Question

 Viewer's Reply
Problem in Connection String
Answered By Moderator1 on 4/8/2010 8:27:08 AM
Hi,

As per the exception you got, I suggest you to change the value you set for connection string. In the article, "YourConnectionString" means you need to replace this word with your connection string. So please check have you set the connection string in your web.config file. if so, you can access the connectionstring with below syntax.

ConfigurationManager.ConnectionStrings["TestCnStr"].ConnectionString

So the Line 4 will look like

SqlDataAdapter da = new SqlDataAdapter(sql,ConfigurationManager.ConnectionStrings["TestCnStr"].ConnectionString);

Try like. It will solve your problem. Good luck.
 
Post Your Reply If you still have problem, post it again under this reply for better response.

 
Sponsored by
No Nonsense XML Web Development With PHP - Free 146 Page Preview!
Sexy Web Design - Free 71 Page Preview!
Windows 8: 50 Questions and Answers You Need to Make a Decision (Normally $9.95)