|
In a C# 2010 application, I created a new linq to sql (*.dbml) file. When this occurred, the .net framework created a default connection string. However I want the *.dml file to use the connection string I specify.
to solve this problem, I have the following questions:
1. When I do create a new .dbml file, how to I make the .net framework use the connection string I want to use and not come up with a default connection string?
2. For an existing .dbml file that I added to the application, how can I change the default connection string to the value I really want to be used?
|
|
|
|
|
Whenever you create instance of DataContext pass the connectionstring in the constructor. This way you will be able to bypass the default connectionstring.
http://www.exploresilverlight.com
Cheers!
Vinod
|
|
|
|
|
can you show me a code example of what you are referring to?
|
|
|
|
|
TestDataContext dataContext = new TestDataContext("connectionstring");
http://www.exploresilverlight.com
Cheers!
Vinod
|
|
|
|
|
For a C# 2010 application, I dragged a new table onto the *.dbml surface. When this occurred, the .net framework changed the exisiting connection string to a default one that it came up with instead of using the existing connection string.
Thus to resolve this question, I have the follwoing questions:
1. When I drag a new table onto the .dbml designer surface, how can I keep the .net framework from changing the existinng connection string and use the existing connection string?
2. For an existing .dbml file that I already dragged the table onto the .dbml designer surface, can can I fix the exisiting code so I do not need to recreate the code from scratch again?
|
|
|
|
|
Some time back I watched a demo from Anders Hejlsberg where he showed how to get the filename and linenumber at compile time by declaring a function using syntax similar to the following:
void log(string message, string filename = _file_, int lineno = _line_)
I don't recall if that was something still being worked on or a proposal or if it is in an actual shipping version of C#.
1. Is this in some version of C#,
2. and if so what version of C# is it in?
3. And what is the actual syntax?
Yes, I know I can get this info in builds where a .pdb is provided through the StackFrame class. That's not what I'm asking.
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|
|
Haha, after a little more searching, I found it here[^]
The syntax is:
public void TraceMessage(string message,
[CallerMemberName] string memberName = "",
[CallerFilePath] string sourceFilePath = "",
[CallerLineNumber] int sourceLineNumber = 0)
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|
|
Tip! Tip!
|
|
|
|
|
Good idea.
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|
|
Interesting.
It is rather new, just available since .NET 4.5
I use Environment.StackTrace (available since 1.0), however that is a very expensive way as it returns the whole stack trace, where one only needs the info about one or two nesting levels.
|
|
|
|
|
Hi This is Chandra,
presently working on GoogleMaps. Right now i can able to bind the langitude and latitude dynamically based on selection of country. That is multiple locations i can able to display in the map.Here my problem is i want to display information window when i click any one of the location. Please find my code below in C~ as well as Asp.net
C# Code:-
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bindInfo();
}
}
protected void bindInfo()
{
try
{
SqlConnection con = new SqlConnection("Data Source=xxx;Initial Catalog=Test;Persist Security Info=True;User ID=xxx;Password=xxx$;Connect Timeout=38000;pooling='true'; Max Pool Size=200");
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "GetCountryNames";
cmd.ExecuteNonQuery();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
ddlPostalCode.DataTextField = "Country";
ddlPostalCode.DataValueField = "Country";
ddlPostalCode.DataSource = ds.Tables[0];
ddlPostalCode.DataBind();
con.Close();
}
catch (Exception x)
{
Response.Write(x.ToString());
}
}
private void GetLocation(string CName)
{
try
{
SqlConnection con = new SqlConnection("Data Source=xxxx;Initial Catalog=Test;Persist Security Info=True;User ID=xxxx;Password=xxxx$;Connect Timeout=38000;pooling='true'; Max Pool Size=200");
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "GetLocationWiseInfo";
SqlParameter param = new SqlParameter();
param.ParameterName = "@Name";
param.Value = ddlPostalCode.SelectedItem.Text.ToString();
cmd.Parameters.Add(param);
cmd.ExecuteNonQuery();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
BuildScript(ds);
}
catch (Exception x)
{
Response.Write(x.ToString());
}
}
public void BuildScript(DataSet tbl)
{
string Locations = "";
foreach (DataRow dr in tbl.Tables[0].Rows)
{
if (dr["Latitude"].ToString().Trim().Length == 0)
continue;
string Latitude = dr["Latitude"].ToString();
string Longitude = dr["Longitude"].ToString();
string Sales = dr["Sales"].ToString();
Locations += Environment.NewLine + " map.addOverlay(new GMarker(new GLatLng(" + Latitude + "," + Longitude + ")));";
}
js.Text = @"<script type='text/javascript'>
function initialize() {
if (GBrowserIsCompatible())
{
var map = new GMap2(document.getElementById('map_canvas'));
map.setCenter(new GLatLng(45.05,7.6667), 2);
" + Locations + @"
map.setUIToDefault();
}
}
";
}
protected void btnPlaceName_Click(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
GetLocation(ddlPostalCode.SelectedItem.Text.ToString());
}
}
ASPX Code:
<asp:label id="lblName" runat="server" text="Please Select PostalCode">
| <asp:dropdownlist id="ddlPostalCode" runat="server" width="150px"
="">
| <asp:button id="btnPlaceName" runat="server" text="GetGeoData" onclick="btnPlaceName_Click">
|
<asp:panel id="Panel1" runat="server">
<asp:literal id="js" runat="server">
<asp:literal id="js1" runat="server">
In the dataset i am getting rows like Longitude, Latitude and sales data based on selection of Country.
Can any one suggest me how to do that?
Thanks
Chandra
|
|
|
|
|
|
|
Hi All,
Is there a tool kit I haven't installed or is it a case of normal with VS2008 but
MessageBox.Show("Hello ","",MessageBoxButtons.OK,MessageBoxIcon.Hand);
gives gives the cross, Asterisk gives i in a speech bubble, Error gives the cross in red, Exclamation gives a ! in a yellow triangle, Hand gives Error, Information the speech bubble with i,None gives nothing, Question gives a speech bubble with a question mark, Stop gives the white cross with the red background and Warning gives the yellow triangle with a !. This must have been updated, cured and I haven't got it, some ones got to know about it?
Glenn
|
|
|
|
|
They are all there only for backward compatibility to Windows 3.1, where the icon was a Hand, held up to show the palm as a "Stop" sign.
Later version of Windows changed the icon (to make it clearer internationally) but the old names were retained so that earlier code would still compile. The original Windows constant values which display them are all the same value: http://msdn.microsoft.com/en-us/library/windows/desktop/ms645505(v=vs.85).aspx[^]
[edit]Typo - "help" for "held" - OriginalGriff[/edit]
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
|
Hello everybody.
I have never woked with networking, and I have a task with it:
On virtual mashine I have a Ubuntu on real mashine I have a Windows, I need to write a programm in Windows which is create a user in Ubuntu. Network connection is setup, mashines are pinging.
I try to use a NFS(Netwerk File System) but I dont know nothing about it... Please help, push me in right side.
How I can do it?
|
|
|
|
|
S.Alexanser wrote: I need to write a programm in Windows which is create a user in Ubuntu
Creating a Windows-program that instructs another application over TCP/IP what to do shouldn't be that hard. I suggest you first focus on that part of the solution.
Second part would be creating the user; what kind of user are we talking about? Do you need to create a local user (?), a database-user (what database?) or a Samba-user (like in a windows-domain?)
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
I think, I need to create local user.
|
|
|
|
|
I suggest you verify that by asking your customer, once you finished the first part of the task.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
S.Alexanser wrote: How I can do it?
First step - figure out how to do it MANUALLY. Thus how do you do it typing at the keyboard.
AFTER you do that then you do one of the following.
1. Find an API that matches what you did manually.
2. Just write code that does what you did manually (see the Process class.)
|
|
|
|
|
I need to visualize a number of appointments on a Grid. In my case an appointment is a UserControl that has a number of properties (e.g. StartDate, EndDate, Subject, ...etc). Now I need to render the appointments in such a way that they do not overlap (pretty much like Outlook).
So far I managed to find out which appointments overlap before adding a new one.
The problem is to find an algorithm that determines the correct Width and X position.
Could anyone help me out on this?
Thanks, Dick
modified 6-Jul-12 7:21am.
|
|
|
|
|
You mean something like this[^]?
|
|
|
|
|
I have a C# 2010 application that I have a question about files in the bin directory. I have created a setup and deployment project and installed the application on a test workstation. Can you tell me what format the application1.dll and application2.dll format files are in? Basically if I want to decompile those dlls, would those applications be in an msil format, a C# 2010 .net format or what format would those files be in?
Next step is I want to see the *.cs code from those two dll files. Thus for example if the code is in an MSIL format, what can I do to get the code in a *.cs readable format?
|
|
|
|
|
Easy. All manged code assemblies are compiled down to MSIL. If you want to see a close approximation of the original source code, use .NET Reflector or some equivilent app.
|
|
|
|