.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Saving database connections

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :

I am trying to save connections in management studio so I don't have to re-enter them every time.  I have to connect to multiple servers and I just want to be able to open management studio and have them already in there.  Is there anyway to do this?


View Complete Post

More Related Resource Links

Does this look correct for saving a file/ new record to a database


So thank you for all your help so far, So I think i got this right,
but would like for you all to look it over to see if there is any
areas I might run into trouble with:

//using asp.net mvc 2
the table (sql server 2005, using entities framework)
table fields
"Pattern_Media_GUID  uniqueid 
"Pattern_GUID  uniqueid
"Media varbinary(max)  
"height int
"Width int
"Media_Type String (50)

the form:
<h2> Add Media to this pattern</h2>
<% Html.EnableClientValidation(); %>
<% Html.BeginForm("AddMedia", "Pattern", new { id= Model.Pattern_Guid} , FormMethod.Post, new {enctype = "multipart/form-data"}); %>
    <%: Html.Label("height") %>
    <%: Html.TextBox("height") %>

    <%: Html.Label("width") %>
    <%: Html.TextBox("width") %>

    <%: Html.Label("Media") %>
    <input type="file" id="Media" name="Media" />
    <input type="submit" name=

Saving textbox data to MySql database in asp.net


Hi dear coders

though a very simple question to ask, but please tell me how to save and retrieve data in/from my textboxes to/from database (MYSQL) on submit button click.

i know its a very simple task but i cant make it done, so i request you to please send me some working example link or post any helpful code here in asp.net

i will be highly thankful for any kind help from you geniuses.



Saving SOAP to Database

Hi All, 

Web Services are very new to me and for the life of me I can not find any info on how to save a soap call/response to the database for a web service.

I did find how to trace them but not save it.

Part of my issue may be that, I am not building a soap envelope for the send. The service I am calling uses different methods to post to itself, e.g.  

api.Execute, api.Create, api.Update and api.Retrieve.

I think these methods are building the envelope for me. If I 'Go to definition' on the Execute method it takes me to the References.cs codebehind page in the application web service for this code.

[System.Web.Services.Protocols.SoapDocumentMethodAttribute("Execute", RequestElementName="ExecuteRequestMsg", RequestNamespace="http://exacttarget.com/wsdl/partnerAPI", ResponseElementName="ExecuteResponseMsg", ResponseNamespace="http://exacttarget.com/wsdl/partnerAPI", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        [return: System.Xml.Serialization.XmlElementAttribute("OverallStatus")

showing modalpopup and saving data to database simultaneously using ajaxtoolkit and javascript

hi,i have a button ,i want that when i click on that button the data should be saved in the database as well as at the same time a modal popup should display the customerid .i have written the code as <asp:button id="save1" runat="server" onclick="Button4_Click" style=""z-index:" mode="hold" xmlns:asp="#unknown" /> left: 740px; position: absolute; top: 304px" Text="save"/> <asp:panel id="panel" runat="server" xmlns:asp="#unknown">  /asp:Panel> <ajaxtoolkit:modalpopupextender id="MPE" runat="server" targetcontrolid="save1" xmlns:ajaxtoolkit="#unknown"> PopupControlID="panel" DropShadow="true" BackgroundCssClass="modalBackground/> protected void Button4_Click(object sender, EventArgs e) { string id = TextBox1.Text; string name = TextBox2.Text; string cn = "Data Source=hcl;Initial Catalog=mydata;Integrated Security=True"; SqlConnection con = new SqlConnection(cn); SqlCommand cmd = new SqlCommand("insert into customer values (@id,@name)", con); con.Open(); cmd.CommandType = CommandType.Text; cmd.Parameters.Add("@id", id); cmd.Parameters.Add("@name",name); cmd.ExecuteNonQuery(); con.Close(); CUSTID.Text = id.ToString(); MPE.Show(); }

dataset not saving to database - what am I not doing? :((

Hello.  Please help me with this one if you have a few mins.  I think I'm overlooking something silly... I have a "hello world" database project.  A mdf database with 1 table "users", the table has 2 columns userid & username (both varchar(50)).  I added a dataset called Database1Dataset.xsd.  I drag the table onto it and it creates the "users" datatable.  I checked it to see if it created the insert and update commands and it has.   On my form I have 2 buttons, one for read and the other for write/save. The read button works and I can see the test records in the database; Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim da As New Database1DataSetTableAdapters.usersTableAdapter Dim dt As New Database1DataSet.usersDataTable da.Fill(dt) For Each dr In dt TextBox1.Text += dr.userid & " - " & dr.username & vbCrLf Next End Sub   The second button should add a new record and save it down to the database but this does not work.  Somehow the changes are not being commited and saved. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim dt As New Database1DataSet.usersDataTable

Updating the viewstate object before saving it to the database


I have overridden the following methods:


SavePageStateToPersistenceMedium(object viewState) 

in a class that my page derives from, so that the viewstate can be stored in DB.

Now, on page_load of my page, I am checking what control caused a postback & based on that I am forcing execution of 2 button click events in a row (by overloading those click events & calling them explicitely), but the behaviour I want is as if the execution of those 2 button click events went through the regular page life cycle.

Here is the sequence of events that happen in typical page life cycle & notice I want to alter behaviour at step 4 (on load):

1) Initialization

2) LoadViewStateData (here the viewstate is loaded from my database using the overridden LoadPageStateFromPersistenceMedium)

3) LoadPostBackData

4) Load

Here, I would like to force execution of 2 button_click events based on whether a particular control posted back.

       4.1) imgBtnPrev5_Click()

       4.2) imgBtnPrev4_Click()

Now, when the imgBtnPrev5_Click() is executed, the viewstate is already loaded, so we are fine. But after execution of imgBtnPrev5_Click(), I would like to update the viewstate object in memory & then call the o

Add Database through App_Data Error- Connections to SQL Server Files (*.mdf) require SQL Express


I am trying to add a new database via the App_Data Folder and I receive an error described below.

I had attached an mdf file to try to use it in SQL Server 2008 Developer and Visual Studio 2010, which was is included in a book's lesson.  Whenever I try to add a database within the App_Data Folder I get an error.

I can create a db by attaching an mdf via SQL Server Mgmt Studio, it connects fine, and I can see tables.

Mgmt Studio- Right Click Databases, Attach, Add, then once mdf is located:

The mdf file location, Database Name, Attach As, -- are all the same:


Do I need to change the Database Name?

Visual Studio- Server Explorer connects fine to mdf OR regular Database, I can see the tables.

However when I attempt to add ANY TYPE OF SQL SERVER DATABASE through the App_Data folder I receive this error "Connections to SQL Server Files (*.mdf) require SQL Server Express 2008 to function properly.  Please verify the installation of the component or download from the URl."

I tested this for both a normal dbo (non mdf) and the mdf.dbo I attached before, with the same error!

Im running XP SP3 w/ Visual Studio 2010 and SQL Server 2008 R2 Developer.  I had previously removed SQL Server Express.

Saving FrameWork Element into a Database

If I wanted to save the content of something which uses frameworkelement, how could I save this into a database field so it can be loaded later on?

Uploading .pdf files with FIle Upload control and then saving to database


Hi everyone!

I'd like to allow users to upload a .pdf file via the file upload control (if that's the best method), save the file to the db and then retrieve it so they can click on a link and open the .pdf they've uploaded.

I've been looking for a tutorial on how to do this but keep running into methods of saving the file directly on the server in a directory, not in SQL server  (using Linq and VB by the way)

Can someone please point me in the right direction on how to do this?   Thanks!

Does ALTER DATABASE SET RESTRICTED_USER block until connections are killed?


Hi, we have a database restore script that runs an ALTER DATABASE [Database] SET RESTRICTED_USER WITH ROLLBACK IMMEDIATE command.  The next statement is a WAITFOR DELAY with 30 seconds.  This is to ensure any non compliant connections are killed before continuing.

However, I'm wondering if the WAITFOR is actually necessary?  Would the ALTER DATABASE command not block until all connections have been killed?


using System.Reflection to saving to database


Hello guy!


I am having challenges saving multiple row to my database using reflection. Each time I cmd.ExecuteNonQuery(), I get the message 'The variable name '@referenceID' has already been declared. Variable names must be unique within a query batch or stored procedure.'

What should i do to resolve this?

Saving an Access database (Powershell)


Here is a fun one. I was told this is the place I’m supposed to ask so here I am.

 I am making a Powershell script that does a bunch of things. The last step is to connect to an Access Database via ADO.net and make an update. I have the basic script from the scripting guys and tried modifying it to my own needs. The Database section is as follows:


$UH = [int]"149995"
$update = " MM/DD: Add text"

$objConnection = New-Object -comobject ADODB.Connection
$objRecordset = New-Object -comobject ADODB.Recordset
$objConnection.Open("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = c:\scripts\User_Help_BE.mdb")
$objRecordset.Open("Select * from [User Help Main Table]",$objConnection,3,3)


while (!($objRecordset.EOF)){
 if ($objRecordset.Fields.Item("ID").Value -eq $UH) {
   $objRecordset.Fields.Item("Tried").Value = $objRecordset.Fields.Item("Tried").Value + $update
	 $UHT = $objRecordset.Fields.Item("Tried").Value
   break }
if ($objRecordset.EOF 

How to handle Daylight Saving Time issues in sql server Database


Hi We have users across the globe and have issues everytime the Daylight Savings change occur. Is there a way to handle this issue in sql server?


web part connections don't remain when saving the page as template



I created a page layout containing 3 List view webparts connected by a page field filter web part.

When I create a page using this template, the filter doesn't have it's value so the connection is broken.

Please help me....


generic use of database connections, commands, datareaders


I have an app that is reading and writing from databases that are structurally identical but are from different systems, primarily SQL Server and Access 2010.  When using the respective .Net objects such as connections, commands, datareaders, the code seems to be often the same (except for transactions - Access doesn't do transactions?).  But the objects are different - sqlconnection versus oledbconnection, etc.

Is there a standard way of writing data access code that works regardless of the database type?

Detach database with drop connections



What is the significance of dropping connections (by chosing drop connection option) while detaching the database? Can it create problems if I don't select this option?



Database mirroring trouble configuring 2 connections


I am trying to set up the following. 


I have configured the sql server side no problem.  i am having issue getting the application that uses the database to connect to the mirrored server in the event of  failure.

The application that utalises the database connects through the data sources (ODBC), System DSN, SQL driver.  I see no option in the configuration for the addition of a 2nd IP.  Many of the technical references i have read refer to the data source connection string, i cannot find this in the registry however.  Please help!

I am used to a 3rd party mirroring software where you connect to a logical IP address which then routes through to whichever database is running.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend