?
Solved

Visial Studio 2003 problem

Posted on 2005-04-28
8
Medium Priority
?
209 Views
Last Modified: 2010-04-07
Hi all,
i have problem and i dont know if its a limitation or a bug in visual studio. I am using asp.net with vb.net on an xp pro and visual studio 2003.
The problem is; when i oledbdataadapter in my web form the connection string is automatically created with it. But i want to use server.mappath in my connection string and the dataadapter wizard wont let this. So i m changing the connectionstring in codebehind but i m getting an error. Error doesnt effect anything and the page runs with no problem but anytime i change someting in the page design (adding a label or deleting a label...) the connection string clears out. If i configure it the way visual studio wants there is no problem.

My question is: is there  a way to set the connectionstring property with server.mappath in design time or is there a way to stop visual studio clearing my custom string after something changes in the page? I can finalize everthing and then change the connection string to my custom string and build my application but i want to know if there is another proper way for this.

any help will be appreciated.
thanks,
-shane
0
Comment
Question by:e106199
  • 4
  • 4
8 Comments
 
LVL 9

Expert Comment

by:BurntSky
ID: 13889682
The reason VS.NET keeps clearing your connection string is because you wrote it in the Designer Generated code area (the block of code it explicitly says not to touch).  The reason you're not supposed to touch anything there is because the designer constantly rewrites this code, therefore erasing any changes you made.

What you can do to solve this is to set the connection string at runtime (in the Page.Load event or even right before you connect your adapter.)
0
 

Author Comment

by:e106199
ID: 13889776
Hi,
i have all my dataadapter and insert/update/delete commands in designer generated code area.So setting the connection string in page load wont be a problem since all the commands are using the connectiong string to do what they are supposed to do right?
thanks,
-shane
0
 
LVL 9

Accepted Solution

by:
BurntSky earned 300 total points
ID: 13890019
You can simply change the connection string at runtime and all your commands will execute as expected. As long as you're not binding at design time, it will all be fine (if you are, your design time data won't show up correctly, but it will still work at runtime.)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:e106199
ID: 13890555
thanks,
i wish visual studio supported server.mappath method but this information is enough for now.
thanks,
-shane
0
 

Author Comment

by:e106199
ID: 13917256
BurntSky,
i m still having problems with the design time connection element.
Here is the real scenerion: i have a grid and its datasource is a dataset which is populated by a dataadapter. All dataadapter and dataset are created in design time by Visual Studio. I have an access db so Visual studio created a connection string that uses the full path of the db file. (i dont know if its possible to tell it use a relative path).
I deleted the connection string created by visual studio and created my own in page_load event. But the select command needs this connection string to populate the grid elements and its giving me the following error message;
Fill: SelectCommand.Connection property has not been initialized.

Do you think i should keep the connection string created by visual studio and set its value to my value in run time?

Or the real solution of my problem is: Can i use relative path in connection string while letting visual studio create it for me?

thanks,
-shane
0
 
LVL 9

Expert Comment

by:BurntSky
ID: 13918870
Honestly, I know it's not the answer you want to hear, but I think you're SOL for the design time issue.  Keep the connection string VS.NET generates for you and then override it at runtime.  Personally, I've always hated how finicky the VS.NET designer is and I just code everything by hand.
0
 

Author Comment

by:e106199
ID: 13919789
Thanks,
thats what i do now. The designer is saving a lot of time but i wish it was more flexible.
-shane
0
 
LVL 9

Expert Comment

by:BurntSky
ID: 13919832
Believe me, I know how you feel.  Hopefully the little issues like this will be fixed in VS.NET 2005.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question