|
Then it's either not executing fine, or you are not looking for the data in the right place. A normal input statement either adds a record or causes an exception when it's executed.
So, most likely you are mistaken in some way, and one of these three things happen:
:: The query is not executed at all.
:: There is an exception, but your code is catching and ignoring it.
:: The data is there, but you look in the wrong place.
---
b { font-weight: normal; }
|
|
|
|
|
hi all,
What is the most Efficient way when using Data Reader and DataSet.?
I have read some articles and they says that Data Reader is Efficient than DataSet.
Now I m giving two samples using DataReader and DataSet.
sample 1 using DataReader)
SqlDataReader dataReader=sqlCmdGetFareList.ExecuteReader();
while(dataReader.Read())
{
FareList farelist = new FareList();
farelist.FareID= dataReader.GetInt32(0).ToString();
farelist.AirlineName = dataReader.GetString(1);
farelistArray.Add(farelist);
}
I'm going to do same procedure using DataSet.
sample 2 using DataSet)
DataSet lobjDataSet=new DataSet("Temp");
DataTable lobjDataTable=new DataTable("DTTable");
SqlDataAdapter lobjSqlAdpt=new SqlDataAdapter(_sqlComm);
//fill DataSet
lobjSqlAdpt.Fill(lobjDataSet);
//fill dataTable
if(lobjDataSet.Tables.Count>0)
lobjDataTable=lobjDataSet.Tables[0];
foreach(DataRow dr in lobjDataTable.Rows)
{
FareList farelist = new FareList();
farelist.FareID= dr["FareID"].ToString().Trim();
farelist.AirlineName = dr["AirLineName"].ToString().Trim();
farelistArray.Add(farelist);
}
In theory says that dataReader is fastest than DataSet.but in here you can see that there is loop in both Sample 1 and Sample 2.
So when considering entire code in sample1 and sample2, can any one please tell me what is the fastest and efficient way to data Retrieve from DB?
Thanks in advance...
|
|
|
|
|
The first one, of course.
The data adapter is basically just reading the data and creating an object structure in memory containing the data. As you are not using any of the added functionality of the data set, this is only wasting time and memory resources.
---
b { font-weight: normal; }
|
|
|
|
|
Guffa is totally right. The fact that you see one loop in both examples doesn't mean anything. You can be sure that the Fill call to the DataAdapter contains another loop. Furthermore you should always consider that one loop may be more/less cost intensive than another one. If you are not sure some logging of the times while running is always helpful. Testing/profiling is always the most secure way to determine which alternative is the best.
|
|
|
|
|
|
Make a public Save method on your MDI child form and then obtain a refrence to the active child form from parent and call the Save method.
--------------------------------------------------------
My development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
Hello,How to set a DataGrid's style(DataGridColumnStyle) when It's DataSource is a DataView?
I can do it when DataGrid's DataSource is a DataSet or DataTable.
Can you Help me?
Thanks a lot.
DataGridColumnStyle
-- modified at 22:47 Sunday 9th April, 2006
|
|
|
|
|
I Have know the answer,Thanks everyone.
hello
|
|
|
|
|
Hey,
i want to do some overloading but i cannot find out how to get the object type to be right.
The problem is the following.
I have a Base class called Animals, and then i have a couple of sub classes which inherit from the Animal class (etc. Dog, Cat and soo on).
I Create my Dog and Cat objects and add them to an ArrayList.
For controlling the ArrayList i have a couple of Methods, one of them is GetAnimal();, which will return a object from the ArrayList. But as it is different what type of objects which is returned it seems that i have to return object of type Animal (the object casted).
I have a class which computes some movement and stuff.
In that class i want to Get an object (GetAnimal()) and call a method, like this.
public void Compute() {
Move(GetAnimal());
}
and then i have Move Methods for every Animal
public void Move(Dog dog) { doSomething }
public void Move(Cat cat) { doSomething }
But my problem is that when i make the GetAnimal() call i get the object as Animal and not as the Correct type needed for overloading. Soo it complains about there is no correct method for overloading.
What am i missing / doing wrong ?
What should i do to get the object as the correct type which i can use when calling the overload methods
I could of course place the methods on the objects and make it abstract instead, but it isnt reall what i want.
Hope someone can help me with this.
Best regards
Martin
|
|
|
|
|
Time to understand the difference between overloading and overriding. Method overload resolution happens at compile time, so the compiler sees that you call Move with an instance of Animal and that there is no method that takes it as a parameter. Virtual method dispatch, which you can achieve by declaring Move virtual or abstract, happens at run time, based on the runtime type of the object returned by GetAnimal. Because the compiler cannot possibly figure the actual type of the object returned by GetAnimal, it can only assume what you've declared i.e it returns Animal.
So no, you cannot do what you want using overloading, unless you return explicit types (GetCat(), GetDog(), for eg.).
Regards
Senthil
_____________________________
My Blog | My Articles | My Flickr | WinMacro
|
|
|
|
|
Thanks for the answer.
I decided to go with the abstract solution as i could probably come in handy later on.
I guess it would have worked if i used the ArrayList with the objects directly and just did something like
Move(theArrayList[index]); -- hmm i am sure i once found an articel on this site about this ... hmm
Best regards
Martin ...
-- modified at 22:16 Tuesday 11th April, 2006
|
|
|
|
|
Hi,
Please see the following code below:
//////////////////////////////////////////////
.....
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
xOrigin = Form1.ActiveForm.ClientRectangle.Width/2;
yOrigin = Form1.ActiveForm.ClientRectangle.Height/2;
DrawThisLine(e.Graphics);
}
public void DrawThisLine(Graphics g)
{
Pen pen = new Pen(Color.Black, 3);
g.DrawLine(pen, xOrigin, yOrigin, xOrigin + 75, yOrigin + 75);
}
private void timer1_Tick(object sender, System.EventArgs e)
{
}
....
///////////////////////////////////////////
I have tried to use the timer1 object and the timer1 event but can't seem to get the line to move around on the Form1. Ultimately I'd like it to rotate around like a clock hand but at this point I'll take any code fragment just to get it in some sort of animated motion.
Thanks a lot in advance....
|
|
|
|
|
Well, as you are not doing anything in the timer event, you can't expect much to happen.
Do some changes to what you are drawing, and cause a redraw:
something += whatever;<br />
this.Invalidate();
You might want to do the drawing on something like a panel, though, so you don't have to redraw the entire window for every update.
---
b { font-weight: normal; }
|
|
|
|
|
THanks,
I intentionally left them blank.
I think my main confusion is the fact that I have to do all the drawing in the paint handler. Once i added the timer event I can't figure out how to tie the the paint event to the timer and the function that draws the line in the paint event.
|
|
|
|
|
That's what the Invalidate call is for. It causes a repaint.
---
b { font-weight: normal; }
|
|
|
|
|
This is my problem, it seems pretty tough.
I have an XML file that is structured like this
<code>
papers
--paper
----id
----title
----tracks
-------track
-------track
-------track
--paper /
--paper
.
.
.
papers /
</code>
SO basically a bunch of paper nodes, each with a track node that has multimpe track chrildren.
So display this data on my page using a repeater
<pre> <asp:repeater id="RepeaterReviewers" runat="server">
<ItemTemplate>
<div class="reviewerListItem">
<div>
<span class="bold"><%# Container.ItemIndex + 1%> </span><%# XPath ("name") %>
(<a href='mailto:<%# XPath ("email") %>'><%# XPath ("email") %></a>)
</div>
<div>
<%# XPath ("affiliation") %>
-
<%# XPath ("country") %>
</div>
<div>
<span>Tracks: <%# XPath ("tracks") %> </span>
</div>
<div><span>
Currently Reviewing: </span><span class="bold"> <%# XPath ("count(papers/id)") %></span>
</div>
</div>
</ItemTemplate>
</asp:repeater> </pre>
but my problem is, I only know how to get back one node using <code><%# XPath ("tracks") %></code> using this syntax. How can I get the value of track nodes inside of tracks????. Remember, I am using a repeater...
/\ |_ E X E GG
-- modified at 16:02 Sunday 9th April, 2006
|
|
|
|
|
How to do it? I need to do some code after any application is started.
For example, I have Win Service and want to write in DataBase any starting application!
|
|
|
|
|
Hi, I am trying to get the color of particular pixel of a panel object, or Graphicx object... can you help me urgently
thanks
|
|
|
|
|
The solution is here:
http://www.gotdotnet.com/Community/MessageBoard/Thread.aspx?id=330183[^]
I've put it in a helperclass so it's easier to use it:
public class PixelGetterHelperclass
{
[DllImport("gdi32.dll")]
private static extern uint GetPixel(IntPtr hDC, int XPos, int YPos);
[DllImport("gdi32.dll")]
private static extern IntPtr CreateDC(string driverName, string deviceName, string output, IntPtr lpinitData);
[DllImport("gdi32.dll")]
private static extern bool DeleteDC(IntPtr DC);
private static byte GetRValue(uint color)
{
return (byte)color;
}
private static byte GetGValue(uint color)
{
return ((byte)(((short)(color)) >> 8));
}
private static byte GetBValue(uint color)
{
return ((byte)((color)>>16));
}
private static byte GetAValue(uint color)
{
return ((byte)((color)>>24));
}
public static Color GetColorFromPoint(Point p)
{
IntPtr displayDC = CreateDC("DISPLAY", null, null, IntPtr.Zero);
uint colorref = GetPixel(displayDC, p.X, p.Y);
DeleteDC(displayDC);
return Color.FromArgb(
GetRValue(colorref),
GetGValue(colorref),
GetBValue(colorref));
}
} I've made a codesample for you to download here: http://sweetsilence.dk/codeprojectprojects/CodeProjectSample_ColorOfParticularPixel/CodeProjectSample_ColorOfParticularPixel.zip[^]
Kind regards - Jakob
Three kinds of people in the world:
- Those who can count..
- Those who can't!
|
|
|
|
|
But what if there is a window over the panel or form at X,Y what color would it return is it the color of the panel or the window over the panel. I tried the same thing before and the results were not as expected. It always returned the color of the top most form, thus to ensure that u get the correct color may be set the TopMost property of the Form TRUE; this is not the best way to do it but u prevent it from getting the color of unwanted windows.
|
|
|
|
|
I don't think there is way to get this working in general, because it interferes with how the Graphics class works. It is merely a wrapper around a target handling graphical input. This could be a bitmap, a panel (like in your case), a printer and much more. As you can image it would be near to impossible to get a pixel color from a graphics which sends all its input to a printer.
Please explain a little more what you are trying to do. Probably there is another way to achieve it. For example I could assume that the Pnael is self drawn by you. If yes than you should double buffer the painting into a bitmap and in the end paint that bitmap onto the panel. Then you could use the buffered bitmap to receive your color (and moreover only regenerate the bitmap when you now the panel has changed).
|
|
|
|
|
f(extract){
//Read the length of the hidden message from the first pixel
pixelColor = bitmap.GetPixel(0,0);
messageLength = (pixelColor.R << 2) + (pixelColor.G << 1) + pixelColor.B;
messageStream = new MemoryStream(messageLength);
}else{
messageLength = (Int32)messageStream.Length;
What is the function of (pixelColor.R << 2) + (pixelColor.G << 1) + pixelColor.B; ????? What is happening in this line ??
AMAN ANWAR
|
|
|
|
|
nwr_mn wrote: What is the function of (pixelColor.R << 2) + (pixelColor.G << 1) + pixelColor.B; ????? What is happening in this line ?
It's just some basic bitshifting to the left
R,G,B are bits like that:
01010110. << 2 will shift this 2 times to the left: 01011000
<< 1 is the same as value*2
<< 2 therefore value*2*2
But this can get risky when you shift a "1" out of the bit range, you end up with a different value then.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
PLZ help me out in Steganogarphy in Bitmaps ............. i am not able to understand how to use the Keystream And the Message Stream >>>>>>
AMAN ANWAR
|
|
|
|
|
There are a lot of articles on this website about this subject. Just go to the search box on the top left corner of this webpage, enter "Steganography", and click enter. I found over 10 articles on the first shot.
|
|
|
|