|
Arunkumar.Koloth wrote: Iam New To C#
In that case you should spend more time studying and practicing the langauage basics before trying an advanced topic such as this.
Arunkumar.Koloth wrote: Thease Statements are not working Correctly
See my previous comment, you have nothing in the above that actually executes any of the methods in your class.
The best things in life are not things.
|
|
|
|
|
Right, your main problem is in your Command method; just set the CommandText property of the existing com field.
You should also have the Command method accept values for Parameters.
|
|
|
|
|
Hi Arun
Try this
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OleDb;
namespace Access
{
public class Connection
{
private string getConnectionString()
{
return "connetionString";
}
public static void ExecuteCommand(string command)
{
OleDbConnection con;
OleDbCommand com;
try
{
con = new OleDbConnection(getConnectionString());
con.Open();
com = new OleDbCommand(command);
com.ExecuteNonQuery();
}
catch (Exception ex)
{
}
finally
{
con.Close();
}
}
}
public void MyMethord()<br />
{<br />
Connection.ExecuteCommand("command write here");<br />
}
|
|
|
|
|
Hello
I think I've discovered some kind of bug here:
I have a ListBox control. I fill its content through DataSource property.
First time I set its width equal to ListBox.PreferredSize.Width, no matter what the real preferred width is, it is set to 120.
From the second time use of PreferredSize.Width it works fine: the width is changed according to the content.
class MyCtrl:UserControl
{
ListBox lb;
public MyCtrl()
{
...
lb = new ListBox();
lb.Visible = false;
lb.Width = 50;
this.Controls.Add(lb);
...
}
public ShowMyListBox(string[] data)
{
lb.DataSource = data;
lb.Width = lb.PreferredSize.Width;
lb.Visible = true;
}
}
Interesting... Is it a bug? Is there any way to fix it?
|
|
|
|
|
Until the control has been fully initialized the preferred size cannot be calculated so the default value is returned. Handling the Load event of the user control and testing PreferredSize in there gives the correct value so you may be better of doing your list box initialization in there.
|
|
|
|
|
Hi everyone
could you tell me what are these? and how we can initialize them?
(1) int[][][] array = new int[3][][];
(2) int[,][][] secondarray= new int[3,2][][];
Thanks
|
|
|
|
|
1 is an array of arrays of arrays of ints, initialized to a length of 3 (that is, the outer array)
2 is an two-dimensional array of arrays of arrays of ints, initialized to a size of 3 by 2 (the outer, 2d array)
They are already initialized, so maybe you meant to ask how to initialize the sub-arrays?
For 1, do array[x] = new int[length][];
For 2, do secondarray[x,y] = new int[length][];
|
|
|
|
|
oh Thanks for your answer it was very helpful,I want to know how can I fill them?
for example
int[][] test= new int[3][];
test[0] = new int[5] { 1, 3, 5, 7, 9 };
....
but I dont know about these arrays can you help me?
Thanks again
|
|
|
|
|
Yes it's also in my message
|
|
|
|
|
What David means is: Every time you create an array, you have to initialize it:
int[] test = new int[3];
Declares a variable that refers to an array of integers, calls it test, and assigns an array of three integers to it. You can now use test[0], test[1], and test[2] perfectly happily.
int[][] test = new int[3][];
Declares a variable that refers to an array of arrays of integers, calls it test, and assigns an array of three integer arrays to it. It does not assign the arrays of integers. To do that, you either need a static declaration, or a loop:
int[][] test = new int[3][] { new int[] { 1, 2, 3 },
new int[] { 4, 5, 6 },
new int[] { 7, 8, 9, 10 } };
Or:
int[][] test = new int[3][];
for (int i = 0; i < test.Length; i++)
{
test[i] = new int[3];
}
You need to repeat the process for each layer of array of arrays you add! Beware: arrays of arrays start to take significant amounts of space, very, very quickly...
These are all "jagged" arrays: the inner arrays are not necessarily the same size.
You can also declare rectangular arrays:
int[,] test = new int[3,4];
This declares a rectangular array of 12 elements in total, and assigns them all. You can happily use test[0,0], test[0,1]... etc.
You can combine them as you did in your example:
int[,][] test = new int[3,4][];
Declares a rectangular array of 12 jagged arrays. You have to initialize each of these to a new array of ints before you can use them, either statically, or in a loop as before.
Note: Normally, I would recommend using a foreach loop rather than a for loop, but that is not possible when filling in jagged arrays, as you cannot change the loop variable:
int[][] test = new int[3][];
foreach (int[] inner in test)
{
inner = new int[3];
}
Will give you a compilation error.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
|
your answer was very helpful for me thank you.
but may I ask a question? what is it? and how can I fill it?
double[ , , ,] m_array4 = new double[,,,];
Thanks
|
|
|
|
|
A 4-dimensional array of doubles - and the first time I've seen one.
Like this: m_array4[x,y,z,w] = 1.0;
|
|
|
|
|
Not like that!
If you look back at my previous answer, that is a rectangular array (doubles or ints, bools or TextBoxes, it doesn't matter what the type is) so you have to tell the compiler how big it is!
double[ , , ,] m_array4 = new double[,,,]; Will give a compilation error, because new double[,,,] does not specify all (or indeed any) of the dimensions. Without them, the space cannot be allocated, and it will complain.
double[ , , ,] m_array4 = new double[3,4,5,6]; Will do it, but - remember I said they get big quickly? - it allocates space for 360 doubles...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
Thanks for answer. 
|
|
|
|
|
These are multidimensional arrays. For more information, see here[^].
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
|
For some reason, while reading a GZip file I am having an issue where it stops after about 24K characters; it never reaches the end of file (I have tried it on several Gzip files of differing sizes, each containing one text file).
I created a small console app to replicate the problem, see below. Any insight would be welcomed...
Framework is .NET 3.5
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.IO.Compression;
namespace GZipDump
{
class Program
{
static void Main(string[] args)
{
UInt64 charsRead = 0;
string file;
if (args.Length > 0)
file = args[0];
else
{
Console.Write("GZip file to be read (full path): ");
file = Console.ReadLine();
}
using (GZipStream gz = new GZipStream(new FileInfo(file).OpenRead(), CompressionMode.Decompress))
{
byte[] bytes = new byte[1];
while (gz.Read(bytes, 0, 1) > 0)
{
Console.Write(Convert.ToChar(bytes[0]));
charsRead++;
}
}
Console.WriteLine("\n\nCompleted.");
Console.WriteLine("Characters Read: " + charsRead);
Console.ReadLine();
}
}
}
|
|
|
|
|
I've never treated the GZipStream like that, but you could try using one of the decompression example out of MSDN found here[^]. If you don't retrieve the original file out of the zip, you may be dealing with a different compression that isn't supported. If you do, then it'd be something to do with how you're reading it out here.
Give it a whirl and see what happens.
|
|
|
|
|
Unfortunately, that example is .NET 4.0 specific. This line:
Decompress.CopyTo(outFile);
Will not work in 3.5, because the CopyTo method does not exist (in fact, if you change the framework version in the link you provided, the example disappears). The example at this url at MSDN (the class page itself) does use the 3-parameter Read method (it is 3.5).
Part of my objective is to "read" the contents of a Gzip file *without* extracting it to disk. However, having it stop early is a problem...
|
|
|
|
|
Now that I have access to VS today, I can test your code. After creating a GZip file with .NET, via the following code:
using (GZipStream gz = new GZipStream(new FileInfo(file).Create(), CompressionMode.Compress))
{
byte[] bytes = File.ReadAllBytes(file);
gz.Write(bytes, 0, bytes.Length);
}
I then ran your code against it and it worked just fine. The question I have is are you accessing a file that isn't local? If so, this may be the source of your problem. Otherwise, you might want to create the zip file with .NET and see if that solves your problem.
|
|
|
|
|
Hello Everybody,
I was create a file with the use of serialize and store here some object information.
then I was create a new project and write code here for deserialize the information.
now it generate some error regarding Assemblyinfo. So pls give me some solution for this issue.
The Error Message is : Unable to find assembly 'serialization' version =1.1.1.1,Culture = Natural,PublicKeyToken = null
If you can think then I Can.
|
|
|
|
|
Have you checked your references? Are you missing one? Is it the correct version?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Are you using the XML serializer? The .NET XML serializer (well, the deserializer side) throws exceptions when it deserializes because of the way its implemented internally. They create an in-memory assembly on the fly, etc. and do a bunch of wacky stuff. It *is* however a handled exception by .NET and you shouldn't even see it inside your application unless you have First Chance Exceptions turned on. Nothing you can do about it besides turning First Chance Exceptions off or going to the binary serializer / deserializer.
|
|
|
|
|
I didn't know that - useful info
|
|
|
|
|