|
Thank you so much, i use them and give you my resault
Hessam jan vaghean mamnunam
|
|
|
|
|
Hi All
I wount set the type of column in DataGridView to combobox how i can do that
and wount to set the DataSourc to Specifyic Table How i can do that
thanks for any body help me
Thaer
|
|
|
|
|
I use the RegAsm.exe to registration the C# Dll but when i try to do CoCreateInstance i don't know where to find the IID of the C# DLL.
Someone can help me please ?
Thanks.
|
|
|
|
|
Thanks for the answear before. I manage to cr8 app to open file as binary, and success.
but..... sometimes it can't read the whole content
This is my code :
<my code><br />
public byte[] readBin(string FILE_NAME)<br />
{<br />
FileStream fs = new FileStream(FILE_NAME, FileMode.Open, FileAccess.Read);<br />
BinaryReader r = new BinaryReader(fs);<br />
int FILE_LENGTH = (int)fs.Length;<br />
int i = 0;<br />
byte[] output = new byte[FILE_LENGTH];<br />
sbyte read;<br />
try<br />
{<br />
while (r.PeekChar() != -1)<br />
{<br />
read = r.ReadSByte();<br />
output[i++] = (byte)read;<br />
}<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show(ex.ToString());<br />
}<br />
<br />
r.Close();<br />
fs.Close();<br />
return (output);<br />
}<br />
</end of code>
It really can read few file perfectly include the file that can't be opened correctly before. but sometimes it still miss a part of file. eg:
a file contain binary like this (opened by UltraEdit32)
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F<br />
10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F<br />
20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F<br />
30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F<br />
40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F<br />
50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F<br />
60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F<br />
70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F<br />
80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F<br />
90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F<br />
A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF<br />
B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF<br />
C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF<br />
D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF<br />
E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF<br />
F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
My code only manage to read
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F<br />
10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F<br />
20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F<br />
30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F<br />
40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F<br />
50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F<br />
60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F<br />
70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
And sometimes it throw an exception like this when open some file.
<small>System.ArgumentException: The output char buffer is too small to contain the decoded characters, encoding 'Unicode (UTF-8)' fallback 'System.Text.DecoderReplacementFallback'.<br />
Parameter name: chars<br />
at System.Text.Encoding.ThrowCharsOverflow()<br />
at System.Text.Encoding.ThrowCharsOverflow(DecoderNLS decoder, Boolean nothingDecoded)<br />
at System.Text.UTF8Encoding.GetChars(Byte* bytes, Int32 byteCount, Char* chars, Int32 charCount, DecoderNLS baseDecoder)<br />
at System.Text.DecoderNLS.GetChars(Byte* bytes, Int32 byteCount, Char* chars, Int32 charCount, Boolean flush)<br />
at System.Text.DecoderNLS.GetChars(Byte[] bytes, Int32 byteIndex, Int32 byteCount, Char[] chars, Int32 charIndex, Boolean flush)<br />
at System.Text.DecoderNLS.GetChars(Byte[] bytes, Int32 byteIndex, Int32 byteCount, Char[] chars, Int32 charIndex)<br />
at System.IO.BinaryReader.InternalReadOneChar()<br />
at System.IO.BinaryReader.Read()<br />
at System.IO.BinaryReader.PeekChar()<br />
at ASCII_test.fileHandle.readBin(String FILE_NAME) in D:\Core Document\Programming\Microsoft Visual Studio 2005\ASCII test\ASCII test\fileHandle.cs:line 43</small><br />
Please someone help me.
Thanks before.
Training makes perfect....
|
|
|
|
|
What are you using sbyte (signed byte) for? Keep it consistent and use byte all the way through.
Why don't you use ReadBytes[^] instead of peeking at the next item and then deciding whether to proceed or not.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
oh yeah. about the sbyte, i forgot to change it back to byte. I use byte before. but I'm get frustated and try many things include change byte to sbyte.
Thank you very much. It really make my app run perfectly as i want.
Training makes perfect....
|
|
|
|
|
Hi,
some more remarks:
1.
it is not common practice to use uppercase for variables (FILE_LENGTH)
and the underscore does not really belong there either; you have a
background in C/C++ I trust, C# coders don't do these things...
2.
there is no need for PeekChar and the End-Of-File test, since you already
know the file length
3.
there is no need for a loop; if you want to hold all the bytes in an array,
just call BinaryReader.ReadBytes(length)
|
|
|
|
|
hi
i want to create list of instance(s) of sql server that was installed on computer, how to do ?
thanks
|
|
|
|
|
Hi there .
A simple way to do this , just send and open empty connection in try catch block
Your connection string can looks like this following code :
<br />
private Boolean TestConnectionString()<br />
{<br />
string sqlServerDefaultConnectionString = "Data Source = (local) ; initial catalog = Master ; Integrated Security = true; ";<br />
<br />
SqlConnection sqlConnection = new SqlConnection();<br />
sqlConnection.ConnectionString = sqlServerDefaultConnectionString ;<br />
try<br />
{<br />
sqlConnection.Open();<br />
return true;<br />
}<br />
catch { return false; }<br />
finally <br />
{ <br />
if (!(sqlConnection == null)) <br />
{ sqlConnection.Close(); <br />
sqlConnection.Dispose();<br />
} <br />
}<br />
}<br />
<br />
DMASTER
|
|
|
|
|
That won't always work. What if there are no default instances of SQL Server installed. e.g. SQL Server 2005 Express Edition instals as an instance called SQLEXPRESS.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
hdv212 wrote: i want to create list of instance(s) of sql server that was installed on computer, how to do ?
This sample[^] may give you the hints that you need to get you on the right tracks.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
There is an article around here that shows how to get all the SQL Server instances on the visible network. Do a search in the C# database articles and you should be able to find it, since it is an app written in C#.
"The early bird may get the worm, but the second mouse gets the cheese" - anonymous, found in Uncle John's Bathroom Reader
|
|
|
|
|
Is it possible to work with generic collections in crystal report?
I defined a generic list like this:
List<Employee> employeeList = new List<Employee>();
And now I want to bind this collection with crystal report and I don't know how crystal report can work with this collection fields in my employee class .
If anybody know please explain in some example .
Thank you very much .
DMASTER
|
|
|
|
|
hi i just wana know the exe of search option present in start menu of windows XP
|
|
|
|
|
Hi,
the search facility in Windows Explorer does not have its own EXE; when you
start a search no new process gets launched. You can verify this with some
system observation tool such as TaskInfo. Hence the search code is part of
what is always loaded, probably explorer.exe itself.
|
|
|
|
|
Draw a fill box on screen. how can i get graphic object of screen or draw a box on screen?
thank you
|
|
|
|
|
Hi
You may use System.Drawing.Graphics and it have Drawline,DrawRectanle ...
|
|
|
|
|
I want to give information about my problem...
I want to build a properties form. When user click a control's properties menu item he/she can see the properties of that control in an other form and can change it at runtime. I have to do this form as a dll and call it from the exe application. What i want to dod is similar to Style Builder in Visual Web Developer. UI will change according to the selected control.
The objects i will work on is not visual studio objects they are different classes and different objects... and i have to get their properties at runtime these objects are not design time objects.
Could you please help me find an optimum solution of this problem.
thanks
-- modified at 3:36 Sunday 5th August, 2007
-- modified at 3:16 Monday 6th August, 2007
sniper47 Computer Engineer
|
|
|
|
|
In .Net you can use System.Windows.Forms.PropertyGrid and some attributes like System.ComponentModel.Browsable , System.ComponentModel.Description System.ComponentModel.DefaultValue and System.ComponentModel.Category for more control over the behavior of the object
how ever if you don't want to use PropertyGrid you can do it by your self using the Type class with methods such as GetProperties().
then you can invoke members here is for property
<br />
<br />
Type myType=myObject.GetType();<br />
System.Reflection.PropertyInfo pi=myType.GetProperty("address");<br />
pi.SetValue(myObject,"street",null);<br />
<br />
and I remember there was a PropertyGrid in vb6.0 if you don't use .Net
I hope the post would be useful
|
|
|
|
|
The objects i will work on is not visual studio objects they are different classes and different objects... and i have to get their properties at runtime these objects are not design time objects.
thank you for your interest
sniper47 Computer Engineer
|
|
|
|
|
Same thing applies. All you have to do is put a PropertyGrid control on your properties form, and then at runtime do:
propertyGrid1.SelectedObject=control; ...where control is the control whose properties you want to show up in the property grid. Then the user can edit the properties without any need for Visual Studio at all. Seems too good to be true, huh? But it is - try it out!
--Justin,
Microsoft MVP, C#
|
|
|
|
|
The below is my code which was written in Webservices. Once I compile it , the "not all code paths return a value" error occurs.
Give the solution of it.
[WebMethod]
public string GetFile(string fileName)
{
string strGetFile = "";
try
{
SPWeb site = new SPSite(srcUrl).OpenWeb();
SPFile spFile = site.GetFile(srcUrl + "/" + fileName);
if (spFile.Length > 0)
{
byte[] fileArray = new Byte[spFile.Length];
strGetFile = System.Text.ASCIIEncoding.ASCII.GetString(fileArray);
return strGetFile;
}
return strGetFile="";
}
catch {}
}
|
|
|
|
|
your method is not void and you didn't handle the catch clause code
[WebMethod]
public string GetFile(string fileName)
{
string strGetFile = "";
try
{
.
.
.
}
return strGetFile="";
}
catch {}//catch{return null;} or catch{throw new Exception("your Exception");}
}
good luck
|
|
|
|
|
The return value of your method is a string, which requires that all exit points from your method provide a value to satisfy the compiler. The following example derived from yours is marked up to show the exit points...
public string SomeMethod(string fileName)
{
string strGetFile = "";
try
{
strGetFile = "some file name";
...
return strGetFile; //==> your optional exit point
}
catch
{
strGetFile = "";
...
return strGetFile; //==> your optional exit point
}
return strGetFile; //==> the main and only required exit point
}
Another way to handle it is to use only one exit point (this makes it easier to maintain as typically multiple exit points generally result in an increase in software maintenance costs over time)...
public string SomeMethod(string fileName)
{
string strGetFile = "";
try
{
strGetFile = "some file name";
...
//ensure the string is set and simply leave the try
}
catch
{
strGetFile = ""; //or some error message
...
//ensure the string is set and simply leave the catch
}
//execution resumes here after the try/catch block
return strGetFile; //==> the main and only required exit point
}
John
|
|
|
|
|
i have 3 page
maste page
header page in side the master page
defalut page
now i want from the default page to change image in header page
how i can do this ??
Palestine
|
|
|
|