|
I found a solution during my googling. But it is not working in my case, can any body please check this code.
this what I found:
public partial class Form1 : Form
{
public static string ConnectionString = "" //your connection string here
DataSet DS = new DataSet();
double TotalRows =0;
double RowIndex = 1;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
OleDbConnection DBConn = new OleDbConnection(ConnectionString);
OleDbDataAdapter DBAdapter = new OleDbDataAdapter();
DBAdapter.SelectCommand = new OleDbCommand("SELECT Count(*) from tblPersons", DBConn);
DBConn.Open();
TotalRows = (int)DBAdapter.SelectCommand.ExecuteScalar(); //retrieve the nr. of rows in the DB Table
DBConn.Close();
DBAdapter.SelectCommand.CommandText = "SELECT * from tblPersons";
DS.Tables.Add(new DataTable("Customers"));
// Add event handler to the row changing event in the dataset
DS.Tables["Customers"].RowChanging += new DataRowChangeEventHandler(Form1_RowChanging);
DBAdapter.Fill(DS, "Customers");
dataGridView1.DataSource = DS.Tables[0];
}
void Form1_RowChanging(object sender, DataRowChangeEventArgs e)
{
if (e.Action.ToString() == "Add") //check if the action is 'Add' (not 'Commit')
{
Thread.Sleep(500);
progressBar1.Value = (int)Math.Round((double)(RowIndex / TotalRows) * 100); //update the progressbar
progressBar1.Refresh();
RowIndex++; //count rows
}
}
}
}
Kutty
|
|
|
|
|
Hi All
I wount set the type of column in DataGridView to combobox how i can do that
and I wount to set his DataSourc to Specifyic Table How i can do that
thanks for any body help me
Thaer
|
|
|
|
|
Hi - nobody helped you 5 hours ago as your question is poorly formed, doesn't make sense and doesn't tell anybody what you have actually tried already to solve your problem.
Posting the same question again is NOT going to make sometbody suddenly thing - "oh darn, I didn't answer Thaer's question - I better do it now."
Form you questions in a clear, concise way, state exactly what the problem is what 'what you have tried to solve it' and you watch the difference.....you will not have to post it twice either. People here WANT to help - but will only help those that want to help themselves, and not those that just want their work doing for them.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
|
|
|
|
|
i have a setup project setup1 which deploys two windows services windows
service1,windows service2.i also added some custom installation actions into
it using projectinstaller.cs.In windowsservice1 oninstall event,i attached a
database ;(create database for attach command) .
in windowsservice2 onuninstall event,i deletes the databse using "drop
database";
the setup exe installs the windows services successfully.but when i
uninstall them, the drop database does not work as sql server places a lock
on mdf files.(cant drop database as mdf file is in use).how can i solve this
problem. Also since uninstall operation is not transactional, only the
windowsservice1 gets uninstalled. when i again try to uninstall ,it shows
"the specified service does not exist as an i nstalled service"(probably the
setup again tries to unstall the already uninstalled windowsservice1).
How can i solve these problems?
i need a way to unlock the mdf files before executing drop database
command
And in unstall event of windows service 1, i need a way to check if it is
already uninstalled
public override void UnInstall()
{
how to check whether the service already uninstalled()?;
base.Uninstall();
}
|
|
|
|
|
Are you sure dropping the database is such a good idea??
What say you just want to upgrade the service??
Ta
Paul
Help, Urgent, Need answers Urgent, Quick Help arggggghhhhhhhhhh
|
|
|
|
|
No.The uninstall operation ,I mean,completely delete the application including db and registry entries .I could not uninstall the application yet.Is there atleast a way to debug the custom install actions?
|
|
|
|
|
I thought you were using an install shield with custom actions, the install shield will worry about all that for you!
Ta
Paul
Help, Urgent, Need answers Urgent, Quick Help arggggghhhhhhhhhh
|
|
|
|
|
Hi, I want to place my windows form 10 pixels from the right side of my user's screen.
But they have different screen resolutions, so i cant place it with a value in pixels.
So do anyone know how to do it?
I'm using this code on my form-load, to place the window:
<br />
this.Height = 175;<br />
this.Location = new Point(0, Screen.PrimaryScreen.WorkingArea.Height - this.Height);<br />
Thanks,
Elias Sorensen
|
|
|
|
|
<br />
int distanceFromRight=10;<br />
int distanceFromBottom=10;<br />
<br />
int screenWidth=Screen.PrimaryScreen.WorkingArea.Width;<br />
int screenHeight = Screen.PrimaryScreen.WorkingArea.Height;<br />
<br />
this.Left = screenWidth - this.Width - distanceFromRight;<br />
this.Top=screenHeight-this.Height-distanceFromBottom;<br />
<br />
or you can use
<br />
<br />
int x = screenWidth - this.Width - distanceFromRight;<br />
int y= screenHeight-this.Height-distanceFromBottom;<br />
<br />
this.SetBounds(x,y,this.Width,this.Height);<br />
<br />
|
|
|
|
|
Hi,
your code is placing the window at the bottom end of the screen, but flush left
since you specified zero for X.
you could replace that zero by an expression that is basically the same as you did
for Y, substituting widths for heights of course.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/AllLanguages/General
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thanks to all. It works perfect now
|
|
|
|
|
Hi Everyone
i've a problem using System.Security.Cryptography.RSACryptoServiceProvider class
when i work with this we must pass the RSA Crytographic parameteres to an object of the RSAParameters class
but they are in the form of Modulus, P, Q, Exponent & ...
we fill the RSAParameteres with these and pass it to the RSACryptoServiceProvider
but i have Public key and Private key from a certificate file, and i haven't Modulus, P, Q, Exponent & ...
i want to know how can i encrypt and decrypt string directly with Public & Private key not with Modulus, P, Q, Exponent & ...
thanx all.
|
|
|
|
|
Asymmetric keys can be created using ToXmlString() method
and can be retrieved using FromXmlString method
it can be done like this:
<br />
AsymmetricAlgorithm asym=AsymmetricAlgorithm.Create();<br />
string myCode=asym.ToXmlString(true);
<br />
RSACryptoServiceProvider rsa=new RSACryptoServiceProvider();<br />
rsa.FromXmlSring(myCode);<br />
<br />
<br />
and if you want the parameters you can use ExportParameters
and of course for converting it to xmlKey you can use ToXmlString again.
if you want get only the key (modulus) part before it you can create the complete key using a little xml operations or filling RSAParameters and importing it using ImportParameters method.
hope the post would be useful
good luck
|
|
|
|
|
So, what you said is completely true in the way of using generated randomly parameters, but id don't want to use them, I have Public Key & Private Key only, and I want to create parameters from them (and not randomly) and then using the parameters to encrypt and decrypt
Nagan ina bisavadan
|
|
|
|
|
|
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
|
|
|
|