***RESOLVED*** sqlconnection technique for deploying

Hi all,

I created a web app(forms) on my test machine and I deployed it on my web server. Now everything was working fine on the test machine but I'm having problems on the web server. This is my first time deploying a web app so I noticed that my code needed some changes. For exemple, I have images in the forms and on my test machine I had them just about anywere on the hard drive. But I didn't think about what would happen on the web server. Anyways I figured out that I had to place them in the directory of the web app in inetpub/wwwroot and had to write the path relative to my application directory. Just an exemple of begginers mistakes.

One problem I can't seem to figure out is the sqlconnection I have. I created an swlconnection in the form but the connection string is for the test machine db. SO on my web server this doesn't work since the machine name isn't the same. I don't know how to change it so it works on both machines at the same time. I thought using localhost would work but I'm having trouble with that.

Here's my string:

workstation id=MYMACHINE;packet size=4096;integrated security=SSPI;data source=MYMACHINE;persist security info=False;initial catalog=Demo2

My db have the same name on both machines (Demo2) but not the workstation id and data source.

What is the best way to write this string so that when deploying I don't have to change everything

Posted On: Sunday 4th of November 2012 06:26:40 AM Total Views:  127
View Complete with Replies

Related Messages:

**resolved**What problem with my server.Transfer code   (135 Views)
I redid that whole application. It worked. It must some property set up incorrectly which I did not notice.
*resolved*Object reference not set to an instance of an object.   (101 Views)
Code:Dim comFacility As New SqlCommand() Dim dataAdapterFaciltiy As New SqlDataAdapter() Dim strCom As String Dim dsFacility As New DataSet() strCom = "SELECT tblFacilities.[Entry-Id], tblFacilities.Facility FROM tblFacilities ORDER BY tblFacilities.Facility;" dataAdapterFaciltiy.SelectCommand.CommandText = strCom dataAdapterFaciltiy.Fill(dsFacility, "tblFacilities") With Me.dpListFacility .DataSource = dsFacility .DataMember = "Facility" .DataTextField = "Job_Name" .DataValueField = "Entry-Id" End With Return dsFacilityI got this error on the red line. I could not see why.
**resolved**which button do I click on web form   (134 Views)
I have a few linkbuttons on the web form. the second post the result according which link button end user click on the first form. How can I know I assumed usingRequest.Form. ... = control name It seems it harder than I expected.Do I need to loop through all the request form control. I read some suggestion about using view state. I am not so good to impliment the viewstate. Will someone shed some light
Finding a LDAP server address *resolved*   (136 Views)
Is there a way to find out what your LDAP address is I was playing with a win form example and ended up with the followingLDAP://dc=MyDomain,dc=comIt seems like the format is LDAP://dc=part,dc=part,dc=part where you put a dc= everytime there is a period. Our domain controler is our ldap server, but if the roles are split up onto multiple machine then you might need and extra dc= for the machine name.Hope this is some use to others looking to use LDAP. :thumb:
Webpage works but Data missing in SQL DB {resolved}   (129 Views)
I have six txt boxes that I need to grab data from and then put into a SQL database. When I press the submit button its suppose to take the data and put it into the sql database. When I go to look in the SQL DB the table is empty. I don't know what I'm doing wrong.Here is my code:Code: Private Sub btnsubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsubmit.Click Dim tmpMedChart As Single Dim tmpFirstName As String Dim tmpLastName As String Dim tmpMidInit As String Dim insert_query As String Dim tmpDOB As String Dim tmpDate As Date 'Dim sqlConnection As New SqlConnection(Me.SqlConnection1.ConnectionString) Dim sqlCommand As SqlCommand Dim oSQLConn As SqlConnection = New SqlConnection oSQLConn.ConnectionString = "Data Source=sqlserver;" & _ "Initial Catalog=Chart;" & _ "Integrated Security=SSPI" tmpMedChart = Request.Form("MedChart") tmpFirstName = Request.Form("FirstName") tmpLastName = Request.Form("LastName") tmpMidInit = Request.Form("MidInit") tmpDOB = Request.Form("DOB") tmpDate = DateTime.Now.ToShortDateString() sqlCommand = New SqlCommand(insert_query, oSQLConn) oSQLConn.Open() insert_query = "INSERT INTO chartassignment (fname, lname, minitial, dob, date, med_chart#) VALUES ('" & tmpFirstName & "' ,'" & tmpLastName & "' ,'" & tmpMidInit & "' ,'" & tmpDOB & "' ,'" & tmpDate & "','" & tmpMedChart & "')" oSQLConn.Close() TraverseControls(Page) 'Clears form Page_Load(sender, e) 'Reloads form End Sub
[resolved]only numeric data entry in a textbox   (113 Views)
With out using a regular expression validator can I allow only numeric data to be entered in a textbox control of my webform.That is if any letters or special characters are entered in my textbox It shd popup an error.Since I have many controls on my webform i cannot have so many regular expression controls for each and every one....Any kind of help is welcome
[resolved] Codebehind - display variable values   (124 Views)
I'm using a codebehind page to insert a record into a table.There's a problem with my insert statement, and I want to display it on the HTML page (.aspx).I'm having fits trying to get the variable with the insert statement to display on the HTML page.I am handcoding the pages.I tried to create the same thing using Visual Studio 2003 -- and it works fine!Then I copy/paste the exact code from the VS generated files to my files, and nothing happens.TIASteve
***resolved***blue wave line under Message.InnerHtml   (100 Views)
in the event of the button, I put in this code.Code:Message.InnerHtml = "Record Added"There will be a blue wave line under message. If I took off the message. then InnerHtml has blue wave line.
Passing values betwwen web froms {resolved}   (139 Views)
Hi all, I hope this question has not been asked before, I'm sorry if it has I did a search but received no hits.Actually its sort of two questions in one but they are on the same topic.First questionI am using and have two web froms in my project. I'm trying to pass the value entered in a text box to the second form when a "submit" button is clicked on the first form.I tried declaring a public string variable on the first form, passing the value of the text in the text box to this variable and then tried to access this variable in the new form. However I get the "etc. is not declared" error. Both forms are part of the same project, so I thought the "Public" identifier would give access to this variable throught the project. Second questionIs there something similar for web forms to the type method that I use in windows forms Ie a popup box that I can use to pass a message to the user without unloading the original formI think that the code below is something like I want for question1 however I don't know enough to translate it to, can anybody help------------------------------------------------------------------------------------------------------------'source web formpublic string Name{ get { return TextBox1.Text; }}public string EMail{ get { return TextBox2.Text; }}--------------------------------------------------'source web form'the server transfer methodprivate void Button1_Click(object sender, System.EventArgs e){ Server.Transfer("anotherwebform.aspx");}--------------------------------------------------'destination formprivate void Page_Load(object sender, System.EventArgs e){ //create instance of source web form WebForm1 wf1; //get reference to current handler instance wf1=(WebForm1)Context.Handler; Label1.Text=wf1.Name; Label2.Text=wf1.EMail;}-------------------------------------------------------
Drop down list to populate data grids [Unresolved]   (134 Views)
Code:Imports System.DataPublic Class WebForm1 Inherits System.Web.UI.Page#Region " Web Form Designer Generated Code " Dim ds As DataSet = New DataSet Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here ds.ReadXml("C:\Inetpub\wwwroot\Conference_Rooms\bin\Conference Rooms.xml", XmlReadMode.Auto) ddlstate.DataSource = ds.Tables(0) ddlstate.DataTextField = "State" ddlstate.DataBind() ddlbuilding.DataSource = ds.Tables(0) ddlbuilding.DataTextField = "Building" ddlbuilding.DataBind() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Dim state As String = ddlstate.SelectedItem.Text Dim sf As String = ddlstate.SelectedItem.Text Dim bf As String = ddlbuilding.SelectedItem.Text Dim dtvCust As DataView = New DataView(ds.Tables(0)) Dim filter As String = "State = '" + sf + "' and Building = '" + bf + "'" dtvCust.RowFilter = filter DataGrid1.DataSource = dtvCust DataGrid1.DataBind() End Subokay i am having two i cant get my drop down lists to contain "distinct" information. It displays a value for every entry in the xml :( not good. Is there any way i can have only read unique entries with out creating seperate xml files second issue is that after i select a building and a state click the button it just chosses the first element in the lis
[resolved] Session problem   (242 Views)
I'm having a problem with sessions and a dropdownlist.I have a dropdownlist in which 2 possible values are. index 0 has 800*600 and index 1 has 1024*768I have following code when the user selects something from the list:Code: Private Sub dropdownMaxSize_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dropdownMaxSize.SelectedIndexChanged Session("maxsize") = CStr(dropdownMaxSize.SelectedIndex) End Subin the overridden prerender I have:Code:Protected Overrides Sub OnPrerender(ByVal e As EventArgs) Label2.Text = Session("maxsize") If CStr(Session("maxsize")) "" Then dropdownMaxSize.SelectedValue = CStr(Session("maxsize")) End If MyBase.OnPreRender(e)end subso what do I want to do I want to keep the value of the selectedindex in a session variable to use later on.PROBLEM: the page starts up with selectedindex = 0 when I select the other, the code part of the selectedindexchanged gets called and it actually stores the "1" in the sessionbut later on when I change the value in the dropdownlist again to 800*600 (selectedindex = 0) it suddenly doesn't call the _selectedindexchange routine anymore and the value in the session variable remains "1" :(I have the autopostback property on true for the dropdownlistis there something I have forgotten to enable to make it postback when you go back to index 0
Sending an e-mail [* Unresolved *]   (131 Views)
,I am trying to create an e-mail application. I have created a simple mail application in win forms. The user will put in the fields and click the send button.I am not really sure how an e-mail application works. But if send an e-mail to my e-mail account i.e. I send the e-mail. However, I never receive the e-mail that I send using this mail application. The application works ok, and there are no run-time errors. Is there something I need to do, to be able to send this to my hotmail, yahoo, or gmail e-mail accounts.The code I have used is below. This has been written in C# Visual Studio 2005.
resolved-Appsetting Error in the Web.config   (220 Views)
I have Configuration Error in the above code.Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: Unrecognized configuration section 'appsettings'Source Error: Line 4: Line 5: Line 6: Line 7: Line 8:
resolved ***enable control***   (134 Views)
when the end user click the check box, I want to corresponding text box enable. I used the following code. It did not work. Since it is server site code. how to write the jscript code run on the client
How to Add Event handling for dynamically created controls -resolved   (91 Views)
Ok so maybe Im going about this the totally wrong way:I've inserted an HTMLTable server control onto my form and am inserting rows and cells which contain html checkboxes into it at run time (coming from a database).Now my question is how do I figure out which checkboxes are checkedHow would I access the event code of these dynamically created html checkboxes so that when I click on them I can reference some page level variable to remember which are checked
Usercontrol - custom properties [resolved]   (272 Views)
I'm just starting with (using visualstudio 2003) and now i'm creating a usercontrol.I would like, if it is possible, to create custom properties for it.For example: The background color of the table that is in the control. Is it possible to create a propertythat shows up in the Property window, so i am able to type in the color i want in VS instead of using changing the codeI need this because i will have to use this control quite often, and change some 'settings' using properties
*resolved*command can't convert to sqlDatareader   (161 Views)
Here is my error on the line:Value of type 'System.Data.SqlClient.SqlDataReader' cannot be converted to '1-dimensional array of System.Data.SqlClient.SqlDataReader'.The code got error.Code: NameReader = NameComm.ExecuteReader(
[unresolved] addition of a label in a treeview   (148 Views)
Here is the situation :I want to add to a treeview named Treeview2 a new label called "NA" but i receive always the same message "no reference to the object", and this, in relation with this part of the codeIf strTag.Substring(0, 2) = "GT" Then I think that we have given the tag "GT" to terms in the Treeview1 and not in the TreeView2 and for this reason there is no reference to the tag "GT" for the terms in the Treeview2. What do you think about. Could you help me to create tag also for the terms in the TreeView2. Here is the entire code we need to understandCode:Private Sub ajout_NA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ajout_NA.Click Dim objInsertNA As SqlCommand, strSQLInsertNA As String, iTermeID As Integer Dim strTag As String Dim iParentID As Integer Dim strParentTag As String Dim n As TreeNode, nParent As TreeNode ' If the new node is to be at the same level then it's parent is the ' currently selected nodes's parent. If Not TreeView2.SelectedNode Is Nothing Then nParent = TreeView2.SelectedNode.Parent End If ' Check the parent is a node before continuing. If Not nParent Is Nothing Then ' Create the new node n = nParent.Nodes.Add(" NA ") strTag = TreeView2.SelectedNode.Tag If strTag.Substring(0, 2) = "GT" Then iTermeID = Integer.Parse(strTag.Substring(2)) End If ' Check if the parent node is a generic terme and if it is get it's ID strParentTag = nParent.Tag If strParentTag.Substring(0, 2) = "GT" Then iParentID = Integer.Parse(strParentTag.Substring(2)) Else iParentID = 0 End If ' Open the DB connection... objConn.Open() ' Insert the terme into the table strSQLInsertNA = "INSERT INTO TERMES(NA) VALUES ( 'New NA' )where ID_TERME = " + iTermeID.ToString objInsertNA = New SqlCommand(strSQLInsertNA, objConn) objInsertNA.ExecuteNonQuery() 'Tag the new node with the it's identity (autonumber) value n.Tag = "GT" + iTermeID.ToString objConn.Close() ' Start the rename of the item n.BeginEdit() End If End Sub
**resolved**Page did not work move to server   (102 Views)
I have web application one page contain the calendar control which work fine in my local machine. When I moved to server. I have the following error message. It only occure in the page contain calendar control . I created another page with the calendar control it work fine in the website.An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [NullReferenceException: Object reference not set to an instance of an object.] PhysicianTutorialManager.Report_Selection_ByDates.Page_Load(Object sender, EventArgs e) System.Web.UI.Control.OnLoad(EventArgs e) +67 System.Web.UI.Control.LoadRecursive() +35 System.Web.UI.Page.ProcessRequestMain() +742I moved all the file over again. It worked. Ty.
**resolved**Add value to add arraylist   (145 Views)
What is wrong with this code