|
Hi,
That´s not working? error not there
reza assar wrote: dataGridview1.DataSource = dataset1.Tables[0];
Datatable as to be empty! if you have only 1 databable in the dataset, just create the table. Bellow i didn´t create a dataset.
Change the routine code to fit your demands.
public static void DataGridView_Fill(DataGridView dgv, string store_procedure)
{
SqlConnection sql_conn = new SqlConnection(connection_string);
SqlCommand sql_cmd = new SqlCommand();
sql_cmd.Connection = sql_conn;
sql_cmd.CommandText = store_procedure;
sql_cmd.CommandType = CommandType.StoredProcedure;
sql_conn.Open();
SqlDataAdapter sql_da = new SqlDataAdapter();
sql_da.SelectCommand = sql_cmd;
DataTable dt = new DataTable();
sql_da.Fill(dt);
sql_conn.Close();
dgv.DataSource = dt;
}
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
hi
what can i do to have a shortcut for click event of a LinkLabel
|
|
|
|
|
Shortcut to what?
Web page / program etc... use System.Diagnostics.Process.Start method.
[Edit]The tag property of the linklabel can be a useful place to store your URL or path etc... you'll have to cast back to string to retrieve the data.[/Edit]
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Im generating a Pdf of a table that contains about 200 000 records, each containig a differen image file too. so my pdf has to draw 200 000 little images, i get out of memory erro or GDI+ error after a while. The code does work for less records (checked on 100 - 1000). the code also works if I delete the image = new PdfBitmap("path for a different image for every cell of the table"); line and draw the same image in every row.
Please any suggestions would be appreciated.
public PdfImage image = new PdfBitmap("l.jpg");
void table_EndCellLayout(object sender, EndCellLayoutEventArgs args)
{
int cellIndex = args.CellIndex;
if ((cellIndex == 5) )
{
PdfGraphics g = args.Graphics;
try
{
image = new PdfBitmap("path for a different image for every cell of the table");
RectangleF bounds = args.Bounds;
PointF point1 = bounds.Location;
//obliczanie srodkowego punku komorki
g.DrawImage(image,point1.X, point1.Y, 30, 30);
}
catch
{
}
}
}
|
|
|
|
|
You should be disposing of any 'new' disposable instances you create, ie PdfBitmap.
That said, I have never seen that class, and there could be other issues involved.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - coming soon ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
I have tried that but maybe Im not doing it right
I cant do image.dispose(). tried
image=null;
and then calling garbage collector..
Im a begginer c# programmer, pls could u write the ideas u have in code?
|
|
|
|
|
hello,
i want to show 5 days before current date and 20 days after current date in a calender control with every date link to a particular page.
plz give me any sample code.
regards
aurosikha
|
|
|
|
|
Windows Forms does not have a Calender control (it does have DateTimePicker), so I suggest you head off to the ASP.NET message board.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - coming soon ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
I know how to insert images to PDF but i need to how can we insert image and image name below it in PDF using C# or Vb or VB.net
RamyaNaidu
|
|
|
|
|
Contact the supplier of your PDF library.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - coming soon ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
|
Use an interface. Simple example below.
public interface IMyInterface
{
void WriteMe();
}
public class A : IMyInterface
{
public void WriteMe()
{
Console.Write("A");
}
}
public class B : IMyInterface
{
public void WriteMe()
{
Console.Write("B");
}
}
public class C : IMyInterface
{
public void WriteMe()
{
Console.Write("C");
}
}
public class D
{
public void WriteParameter(IMyInterface test)
{
test.WriteMe();
}
}
Then you can do this
D d = new D();
d.WriteParameter(new A());
d.WriteParameter(new B());
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Thanks a lot Dave this code worked for me.
|
|
|
|
|
If I understand what you want (and I probably don't), what you want to do is called oveloading.
public class A
{
private List<a> list = new List<a>();
public List<a> GetAllRecords() { get { return list; } }
}
public class B
{
private List<b> list = new List<b>();
public List<b> GetAllRecords() { get { return list; } }
}
public class C
{
private List<c> list = new List<c>();
public List<c> GetAllRecords() { get { return list; } }
}
public class D
{
private A a = new A();
private B b = new B();
private C c = new C();
private List<a> aList;
private List<b> bList;
private List<c> cList;
public D()
{
}
private List<a> GetAllRecords(A a)
{
aList = a.GetAllRecords;
}
private List<b> GetAllRecords(B b)
{
bList = b.GetAllRecords;
}
private List<c> GetAllRecords(C c)
{
cList = c.GetAllRecords;
}
}
[EDIT] Forgot to convert the pointy brackets...
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
modified on Saturday, October 11, 2008 5:08 AM
|
|
|
|
|
Hello friends,
I'm using Visual Studio 2005. I'm developing an application that extracts icons from .exe and .scr files and saves them into a MS-Access database. I've created a OLE Object field in the database table for the icons. I use the Icon.Save() along with an instance of the MemoryStream class to get raw icon data bytes into an array. My problem is that Icon.Save() method saves the icon as a 16-color image. I want to know how can I save the icon with no quality loss.
Also, are there any alternatives to the MemoryStream class?
Many thanks in advance.
|
|
|
|
|
hi
this is a good example for loading and saving icons.
http://www.codeproject.com/KB/cs/IconLib.aspx
regards
|
|
|
|
|
Can any body in which situations we use value type and for which situations we use reference types for passing parameters to function.
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
i think when u have simply to do some calculations or just require temprerory variable to do ur oprations then u can go for value type
and if u want to reuse the same object among diffrent functions which have
dependency on operation done on that object by other funcions then u should go for reference type.
rahul
|
|
|
|
|
If you want the value from outside the function to be changed within the function, use a reference type.
If you want to pass a value from outside the function but not let the function change the original then it needs to be a value type or a clone of the reference type.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Hi Dave,
If i pass parameter as reference type, for eg. if i pass every thing as ref type then is i am saving memory because no extra memory is required in heap , if i pass parameter as ref.
Tell me i am correct or not.
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
I'm no expert in stack/heap stuff, so if what I type below is erroneous, would one of the CP gurus please correct it!
Value types are placed on the stack, reference types are placed on the heap but the reference to them are placed on the stack. A method's parameters are placed on the stack - either a copy of the value type, or a copy of the reference to the reference type, therefore the heap doesn't come into the equasion at all.
Extra stack space is taken whichever way you do it. Reference will be more efficient if you would otherwise be passing large structs (value types), but the stack is very efficient so I wouldn't worry too much.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
You inspired me to read up on this a little!
This[^] is a well explained article. Hope you find it to be of some use.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
This article supports that if you pass very big collection then u should pass by reference.
Am I rite.
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
Yeah. If passed by value, data is copied and you don't want to be creating multiple copies of a large amount of data. In that scenario it's better to pass by reference so only a copy of the reference is made.
If it's only a small amount of data then there may be a performance advantage to using a struct to keep the heap and GC out of it altogether.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Hi
I have a windows service application that reads service 'StartTime' , 'IntervalTime' from configuration file and runs my method that do the job at specified time and time intervals. That works absolutely fine by reading the start time and Interval Time (interval time to wait to run the service again).
But the problem is when yearly timings changes. In United Kingdom we get timings change twice explained below for this year. This varies year to year:
Clocks went forward one hour on Sunday 30 March 01:00 GMT* (02:00 BST)
* As the UK is currently on GMT, we changed our clocks at 1 am on Sunday 30 March.
Clocks moved one hour backwards. Sunday 26 October 02:00 BST** (01:00 GMT )
**As the UK is currently on BST (British Summer Time), we will change our clocks at 2 am on Sunday 26th October.
How it works just now:
Currently my service starts at start Time specified in configuration file and again after specified interval Time in config file. For example 1000 is start time and interval Time[should be specified in milli seconds] is 86400000[Equals 24hrs]. My service starts at 1000 Today and runs and then sleep for 24hrs AGAIN runs at NEXT DAY 1000. During this 24hours sleeping if day light time is changing, my service will be out of sync.
Only change i like to be done is: Timer object checks system time every minute to find out if it is the time to run the service or not. That way we can hanlde day light savings time changes i think.
Note: May be by checking time every minute to see if current Time is the Time to run the service method or not.
1 public partial class myService : ServiceBase
2
3 {
4
5
6
7 System.Threading.Timer timer;
8
9 public myService()
10
11 {
12 InitializeComponent();
13 }
14
15 protected override void OnStart(string[] args)
16
17 {
18
19 try
20
21 {
22
23
24
25 string startTimeString = ConfigurationSettings.AppSettings ["StartTime"].ToString();
26
27
28
29 DateTime startTime;
30
31
32
33 int millisecondsToStart = 0;
34
35 if (DateTime.TryParseExact(startTimeString, "HHmm", CultureInfo.InvariantCulture, DateTimeStyles.None, out startTime))
36
37 {
38
39 if (DateTime.Now > startTime)
40
41 startTime = startTime.AddDays(1);
42
43 millisecondsToStart = (int)startTime.Subtract(DateTime.Now).TotalMilliseconds;
44
45 }
46
47 timer = new System.Threading.Timer(OnElapsedTime, null, millisecondsToStart, Convert.ToInt32(ConfigurationSettings.AppSettings["intervalTime"]));
48
49
50 }
51
52 catch (Exception ex)
53
54 {
55
56
57
58 System.Diagnostics.EventLog.WriteEntry("error in starting my Service", ex.Message + Environment.NewLine + ex.StackTrace);
59
60 }
61
62 }
63
64
65
66 protected override void OnStop()
67
68 {
69
70
71
72 }
73
74 private void OnElapsedTime(object source)
75
76 {
77
78
79
80 TransferData();
81 }
|
|
|
|