|
I never understand why people save their connection strings in web.config... how unsecure is that?
This is how I avoid your problem:
1) In global.asax I have a function like this:
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
Select Case Server.MachineName.ToLower
Case "aaaaa"
' local
Application("ServerName") = "local"
Case "bbbbb"
' laptop
Application("ServerName") = "laptop"
Case Else '
' live
Application("ServerName") = "live"
End Select
End Sub
You will need to find out, if you don't know already, your local machines name. User Server.MachineName in any aspx page to find out if you need to.
2) I then make a publicly available function such this:
Public Class myFunctions
Public Function dbConnection(ByVal ServerName As String) As String
Select Case ServerName
Case "live"
Return "data source=xxxxx;initial catalog=xxxxx;uid=xxxxx;pwd=xxxxx"
Case "local"
Return "data source=yyyyy;initial catalog=yyyyy;uid=yyyyyy;pwd=yyyyyy"
Case "laptop"
Return "data source=zzzzzz;initial catalog=zzzzz;uid=zzzzz;pwd=zzzzz"
End Select
End Function
End Class
3) Then I can use the same code throught my app to connect to the database on whateve computer I am running on:
Dim myFunction As New myFunctions
Dim objConn As New SqlClient.SqlConnection
objConn.ConnectionString = myFunction.dbConnection(Application("ServerName"))
Works a treat!
-- modified at 15:11 Tuesday 28th August, 2007
Of course, you don't acually need to use the Application object at all, but could call the function directly with
objConn.ConnectionString = myFunction.dbConnection(Server.MachineName)
if you replaced the Select..Case in the dbConnection function with the amchine names there instead of the aliases I created. But there was a reason I did it this way when I first came up with it - just can't remember what it was now! - and I have always done it the same way since!
Fred
|
|
|
|
|
Dear All,
I am placing an image button inside a gridview:
<asp:GridView ID="equipmentGrid" runat="server" AutoGenerateColumns="false" OnRowCommand="equipmentGrid_RowCommand">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton i="image" runat="server" ImageUrl='<%# Eval("equipment_image", "~/Images_Equipment/Small/{0}") %>' CommandName="imageClick" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="category" HeaderText="Category" HtmlEncode="false">
<HeaderStyle HorizontalAlign="left"/>
<ItemStyle Wrap="true" HorizontalAlign="left" Width="50px" />
</asp:BoundField>
|
|
|
protected void equipmentGrid_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandSource=="image")
{
Response.Redirect("http://www.google.com");
}
}
I want to be able to handle the click of the imagebutton. I tried using onrowcommand but the application is not even accessign the method it just returns an in valid postback error.
I tried modifying the event validation to true but no success. the error does not pop up but the method is still not invoked.
Thanks a lot
Chris
|
|
|
|
|
Change your if statement to check the e.CommandName instead of e.CommandSource.
if(e.CommandName == "imageClick")<br />
{<br />
Response.Redirect("http://www.google.com");<br />
}
I also noticed that your ImageButton id said i="image" instead of id="image" but that could just be a typo.
<asp:ImageButton i="image" runat="server" ImageUrl='<%# Eval("equipment_image", "~/Images_Equipment/Small/{0}") %>' CommandName="imageClick" />
Nathan
|
|
|
|
|
Hi,
How to use LDAP Authentication....
This is the documents:-
Internet on basis of the access rights granted to the logged in user. This web application will use through LDAP authentication.
pls tell me...How to strat...i need full Documents...
advance thanks
thank you,
Somasundaram
|
|
|
|
|
In order to test LDAP, you need to have Active Directory installed in your LAN. and (of course) you need to have the access permission to access this service from Server (Windows Advanced Server 2000 or Windows 2003 Server).
Then, you can try to access like that..
Eg from Implementing Active Directory Services in ASP.NET 2.0:
Dim adsRoot As New DirectoryEntry("LDAP://OU=ADSI,DC=ent,DC=ds,DC=microsoft,DC=com")<br />
<br />
Dim adsSearch As DirectorySearcher = New DirectorySearcher(adsRoot)
You can google about this[^] if you want more details about how to use DirectoryService in your project...
Hope it helps..
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Hello,
iam looking for a char control for asp .net 1.0 with features how:
.zoom
.map
.chart types
some one can guide me
thanks for the time
regards
|
|
|
|
|
I have made a small ASP script.
But I don't know how to insert that script in HTML document. Because I think, if I insert this script in that HTML document, it will work on a server, if not it will not work.
|
|
|
|
|
In order to run an asp script it should be placed in an asp file and NOT an html file. This file should be placed on a server running IIS or a similar web server supporting asp/.net suc as cassini. When accessed from the server, the page is rendered an html data is displayed in the browser.
You seem to be quite a beginner hence I suggest to get up a good book and try to move steb by step with it.
Should you have any queries please do contact me.
Thank you very much
Chris
|
|
|
|
|
hi I want to deploy my asp.net application running on iis 6, on windows vista home premium edition that runs iis 7??
is that possible..if so how??
I already created the web setup for the application (.msi and .exe) files to install the application on the localhost of the computer having windows vista but it cannot be installed, I dunno why??
|
|
|
|
|
Nada Adel wrote: I already created the web setup for the application (.msi and .exe) files to install the application on the localhost of the computer having windows vista but it cannot be installed, I dunno why??
What is the error message that you get when you run the installer?
Pete Soheil
DigiOz Multimedia
http://www.digioz.com
|
|
|
|
|
something like that:
The installation is incomplete, or has been interrupted, please restart windows installer...something like that
|
|
|
|
|
Nada Adel wrote: something like that:
The installation is incomplete, or has been interrupted, please restart windows installer...something like that
Have you tried to manually deploy your project (basically copy the whole project folder over to the client machine, create a folder for it under IIS Manager and change its property to application type)?
Pete Soheil
DigiOz Multimedia
http://www.digioz.com
|
|
|
|
|
Hi i have list of values in my dropdownlistbox...,
All those want to be store in my table...,
How to do that?
Ex:
This is my code:
Dim strinsertproc As String
strinsertproc = "submitManPowerDetails '" & Val(ddlContractor.SelectedItem.Value) & "','" & Val(ddlProject.SelectedItem.Value) & "'"
sqlcmd = New SqlCommand(strinsertproc, sqlconn)
sqlcmd.Connection.Open()
sqlcmd.ExecuteNonQuery()
sqlcmd.Connection.Close()
sqlcmd.Dispose()
See in that ddlproject is dropdownlistbox...,
The above code will store which value have selected that one only...,
But instead of that in that what are the values that dropdownbox contains, all the values want to store in my table...,
How to do that one...,
Plz hlp me,
Regards,
Magi
|
|
|
|
|
How do you populate your drop down list? Do you use a stored proc or some other method to populate the drop down list? You will need to change your insert stored proc to accept a varchar and then pass in the values populated in your drop down list via a string array. I am still confused at why you would want to save this information though. Your insert proc should only be inserting what was selected by the user and adding that to your database table. Will the items in your drop down list be changing very often?
Nathan
|
|
|
|
|
hi everybody,actually am having an xml file which contains the links of some 50 images.now i need to retrive the xml file by specifying the url using asp.net ajax through web browser.the images could be intially in thumbnails.
wat would be the better option to do this.?
am new to ajax..pls do help me..
|
|
|
|
|
even i`ll like to do something like this. please let me know..
thx
Kunal
|
|
|
|
|
Hi,
One of my webmethods throw an exception:
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: The provided Supervisor emailID either invalid or do not exists in the database at ManageEmployeeServices.AddEmployee(Int64 EmpID, String EmpName, String EmpEmailID, String SupervisorEmailID, String LocationName) in c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\WebSites\ManageEmployeeServices\App_Code\ManageEmployeeServices.cs:line 53 --- End of inner exception stack trace ---
And In my client I want to display only the bolded text as it is the actual error message. So how can I trunctate all the unwanted string from the error message?
Thanks:
Rakesh
|
|
|
|
|
Try this?
[WebMethod]
string MethodName
{
try
{
..Your Code
return "";
}
catch (SqlException ex)
{
return ex.Message;
}
}
So in the event of an error, your method will return the error message, otherwise returns an empty string, or null if you prefer?
|
|
|
|
|
hi,
My intention is to return a dataset from the web method so how can I mention the return type as string?
Regards,
Rakesh
|
|
|
|
|
You can declare the dataset outside of the Try block, and in the event of an error, add an Errors Table too it that contains all of the info. Then check for the existance of that table on the return trip.
|
|
|
|
|
Great! that worked... Thanks a lot.
Rakesh
|
|
|
|
|
hi guys
i have serious problem here, i am embedding a image into a hyperlink as show below,, the onmouseover and onmouseout is working fine in the image properites shown below,,
in the same page i have a button control which will open a pop up window,,as the pop up window is in focus...i move the mouse over to this image.. the onmouseover event is raising for both the image control when i scroll across these two images ... how to solve it, this happens only if i click the button control, otherwise its working fine
winnie
|
|
|
|
|
hai all,
i have develop web application using c# with asp.net....
i need the solution for
"when the pageload the cursor pointout automatically particular textbox "....
if anybody know ...pls reply me with source code....
Thanks And Regards,
vidyasankar
More pain gives More gain
|
|
|
|
|
TextBox1(ID).Focus(); Just call it like this on the page load.
SSK.
|
|
|
|
|
Thanks for your response... i do that but its not working good...
and i got another solution...
(i.e)
Page.RegisterStartupScript("setfocus", " document.forms[0]." + TextBox1.ClientID + ".focus(); ");
its working good...
regards,
vidyasankar
pain gives gain
|
|
|
|