|
Yeah, but you've got the yellow diamond.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
|
Ok so this is my class called settings.cs I dont know where I am going wrong but it does not like the code it gives me the following errors:
Error 1 Invalid token '{' in class, struct, or interface member declaration
Error 2 Invalid token '{' in class, struct, or interface member declaration
Error 3 Invalid token '.' in class, struct, or interface member declaration
there is a total of 15 errors any help would be greatly appreciated!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestApplication
{
public static class Settings
{
private static string _connectionString = string.Empty;
public static ConnectionString
{
get
{
if (string.IsNullOrEmpty(_connectionString))
_connectionString = ConnectionManager.ConnectionStrings["connection_string_stored_in_config_file"];
return _connectionString;
}
}
}
}
|
|
|
|
|
Terence van Schalkwyk wrote: public static ConnectionString
should read
public static string ConnectionString
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
thanks that fixed it!
Last question:
_connectionString = ConnectionManager.ConnectionStrings["connection_string_stored_in_config_file"];
where do you specify ConnectionManager?
Thanks again!
|
|
|
|
|
Sorry, that should have read ConfigurationManager.ConnectionStrings; add a reference to System.Configuration . This is what happens when I write code directly on the Code Project web site. I'll edit the original code to show what it should be.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I am using visual studio 2008....
Thanks for that!!! I hope this is the last question!!! Its still not liking ConfigurationManager. Does not exist in current context. Am I supposed to initialise this somewhere?
Also in this part of the code "connection_string_stored_in_config_file" is this the section in the config file?
Here is how my code looks:
using System.Configuration;
namespace testapp
{
public static class Settings
{
private static string _connectionString = string.Empty;
public static string ConnectionString
{
get
{
if (string.IsNullOrEmpty(_connectionString))
_connectionString = ConfigurationManager.ConnectionStrings["connection_string_stored_in_config_file"];
return _connectionString;
}
}
}
}
Here is my App.config file. Is this correct so far and how do I put my connection string in?
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="MyConnection" connectionString=""></add>
</connectionStrings>
</configuration>
modified on Monday, May 3, 2010 7:00 AM
|
|
|
|
|
Terence van Schalkwyk wrote: Its still not liking ConfigurationManager
You need to add a reference to System.Configuration. It's not included in your list of references - right click on your reference, select Add reference and choose it from the .NET tab.
Terence van Schalkwyk wrote: _connectionString = ConfigurationManager.ConnectionStrings["connection_string_stored_in_config_file"]
Now that we know what you are going to call your connection string, change this line to:
_connectionString = ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString; The connection string you add in here largely depends on the database type and connection details. There is a handy online resource that shows many different types of connection string - it's available here[^].
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
hi
i want write one program in c#
i have very images in this program and i want user can not copy my pictures load in my project ,
with print screen button or other softwares like snagit
please help !!!!
thanks
|
|
|
|
|
Can't be done. Every file can be copied and anything you put on the screen can be captured by any decent screen capture prog.
|
|
|
|
|
Dave Kreskowiak wrote: anything you put on the screen can be captured
For some reason, I have trouble capturing frames from video that plays on my computer. I wonder if that could be utilized to prevent a screen capture of an image. I think it has something to do with hardware acceleration, though it may be a quirk of my video card.
Dave Kreskowiak wrote: Every file can be copied
Embedding them and encrypting them could make it at least difficult to copy files.
|
|
|
|
|
In your video case it might be because the video player is using DirectX. There are programs out there that can grab DirectX output images. You just need to do a search on that. You may want to take a look at this article: Various methods for capturing the screen[^]
|
|
|
|
|
loyal ginger is called: loyal ginger
Prejudice
(watch the whole thing, as it's not what it seems when it starts)
|
|
|
|
|
|
PrtScrn hes problem capturing DirectX video as well as otehr windows that use transparency. PrtScrn sucks but is easily replaced by other screen capturing apps that do a much better job and don't have the limitations of PrtScrn.
aspdotnetdev wrote: Embedding them and encrypting them could make it at least difficult to copy files.
Copying the files is easy. Decrypting the data is harder.
|
|
|
|
|
Dave Kreskowiak wrote: Copying the files is easy. Decrypting the data is harder.
Lol, true.
|
|
|
|
|
aspdotnetdev wrote: have trouble capturing frames from video that plays on my computer
Yeah that'll be the hardware acceleration, what windows actually puts up is some predefined overlay colour and the graphics card graciously fills this colour in with the video as it passes through. So when you take a screen capture you just capture a dark purple block.
If you find what the overlay colour is you can fill a block of it in inside ms paint, and watch any currently playing videos on it.
My current favourite word is: Smooth!
-SK Genius
|
|
|
|
|
SK Genius wrote: If you find what the overlay colour is you can fill a block of it in inside ms paint, and watch any currently playing videos on it.
I always wondered why it did that. Thanks for the info!
|
|
|
|
|
How to get selected item for DropDownList .And this DropDownList is inside GridView.
|
|
|
|
|
"In the DropDownList Tasks menu, choose Edit DataBindings.
The SelectedValue property of the DropDownList control is selected in the DataBindings dialog box."
See here for a walkthrough.
|
|
|
|
|
please clarity more.. and read the question.
|
|
|
|
|
SqlConnection con1 = new SqlConnection();
con1.ConnectionString = ConfigurationManager.ConnectionStrings["Connectionstring"].ToString();
string sql1 = "select " + colu + " from " + tbl + " where " + cond1 + " ='" + value1 + "' and " + cond2 + " = " + value2 + "";
SqlCommand cmd1 = new SqlCommand(sql1, con1);
con1.Open();
SqlDataReader dr = cmd1.ExecuteReader();
while (dr.Read())
{
return dr["ZoneCode"].ToString();
}
con1.Close();
Error:
Compiler Error Message: CS0161: 'Adv.ReturnString(string, string, string, string, string, string)': not all code paths return a value
Line 51: public string ReturnString(string tbl, string colu, string cond1, string value1, string cond2, string value2)
p
|
|
|
|
|
Remove the return from inside the while loop and place it outside.
Return a collection of ZoneCodes instead of doing what you have done above.
<pre>SqlConnection con1 = new SqlConnection();
con1.ConnectionString = ConfigurationManager.ConnectionStrings["Connectionstring"].ToString();
string sql1 = "select " + colu + " from " + tbl + " where " + cond1 + " ='" + value1 + "' and " + cond2 + " = " + value2 + "";
SqlCommand cmd1 = new SqlCommand(sql1, con1);
con1.Open();
SqlDataReader dr = cmd1.ExecuteReader();
List<string> objList = new List<string>();
while (dr.Read())
{
objList.Add(dr["ZoneCode"].ToString(););
}
return objList;
con1.Close();</pre>
You method signature will be
<pre>public List<string> ReturnString(string tbl, string colu, string cond1, string value1, string cond2, string value2)</pre>
Sorry. I cannot include this code in the <pre> tags. The generics part is getting messed up.
|
|
|
|
|
Compiler Error Message: CS0246: The type or namespace name 'List' could not be found (are you missing a using directive or an assembly reference?)
|
|
|
|
|
Abdul-Rhman Alsri wrote: Compiler Error Message: CS0246: The type or namespace name 'List' could not be found (are you missing a using directive or an assembly reference?)
You need to include the Systems.Collection.Generic namespace.
modified on Sunday, May 2, 2010 2:43 AM
|
|
|
|