|
is there any way to import CSV file to datagridview without all the procedure of connectionstrings and querys????? i want only to imports the parameters of the CSV to the table.....
10x...
Ido
|
|
|
|
|
You can read a CSV into memory as a string array using File.ReadAllLines and use the split method to split on the comma to get your fields.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
I love it when I can do this - CSVtoTable[^]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Great! lovely 10x!!!!
|
|
|
|
|
|
how using properties inheritece?
how chage one properties and then the inherited that i selected take changed?
ex:visible property in text chaged so lable visible propertes changed.because i select lable visilbe properties to inherite from text visible propertis.
thanks
|
|
|
|
|
What
If you give us a proper example of what you want, we may be able to help you achieve it. Try to be a little clearer as the above makes no sense at all.
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) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
If I understand you, which I doubt
generate a VisibleChanged Event for your TextBox
private void aTextBox_VisibleChanged(object sender, EventArgs e)
{
aLabel.Visible = aTextBox.Visible;
}
|
|
|
|
|
i want to thank the all of the pepole that help ech other to improve .
thanks i think i gi ve my answer.
thank u . thank u . thank u.
|
|
|
|
|
Hi
In my application I want to view Windows' Safely Remove Hardware screen from a button instead of clicking the hardware icon on taskbar to see inserted flash disks.
Is there a function to call?
can anyone help me?
|
|
|
|
|
Maybe this article[^] can help?
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) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
|
Can I get the special xml strings (< & etc) directly instead of being translated?
For example, given the data "RCI>", the code:
xmlReader.ReadStartElement("DATA");
data = xmlReader.ReadString();
xmlReader.ReadEndElement();
Gives: "RCI>". Can I get the raw "RCI>" and if so, how?
Thanks
|
|
|
|
|
use
String.Replace Method
*12Code
|
|
|
|
|
|
That's the one.
Thanks very much.
|
|
|
|
|
I have this code in my project:
<br />
string str;<br />
byte[] enc = new byte[str.length];<br />
enc = Convert.FromBase64String(str);<br />
when i trace it, in the 2nd line the enc is a byte with the length of str but when 3rd line executes the enc length becomes 1 and therefore my data is not valid at the end.
does anybody know what should i do?
Roshanak
|
|
|
|
|
You should know that the base64 encoding is a bit verbose.
I.e. Silly question, silly answer (i.e. please post input values, expected output, actual output if you want better help).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
You didn't assign any string to str.
What do you expect enc should be?
*12Code
|
|
|
|
|
The assignment part of second line is not having any use. Your field will be having the return value from FromBase64String method.
Also the length of encrypted string and decrypted string wont be same.
|
|
|
|
|
I'm trying to encrypt sth, and those lines were just a part of my code. I'm sorry for not being clear but i wanted to be brief,
this is the whole code:
<br />
using System;<br />
using System.IO;<br />
using System.Text;<br />
using System.Security.Cryptography;<br />
<br />
namespace Cryptography<br />
{<br />
<br />
public sealed class Cryption<br />
{<br />
private RijndaelManaged Algorithm;<br />
<br />
private string m_key;<br />
private string m_iv;<br />
<br />
private byte[] key;<br />
private byte[] iv;<br />
<br />
<br />
<br />
public Cryption(string key_val, string iv_val)<br />
{<br />
key = new byte[32];<br />
iv = new byte[32];<br />
<br />
int i;<br />
m_key = key_val;<br />
m_iv = iv_val;<br />
<br />
for (i = 0; i < m_key.Length; i++)<br />
{<br />
key[i] = Convert.ToByte(m_key[i]);<br />
}<br />
for (i = 0; i < m_iv.Length; i++)<br />
{<br />
iv[i] = Convert.ToByte(m_iv[i]);<br />
}<br />
<br />
}<br />
<br />
<br />
public string Encrypt(string s)<br />
{<br />
string enc_str;<br />
byte[] enc_byte;<br />
<br />
Algorithm = new RijndaelManaged();<br />
<br />
Algorithm.BlockSize = 256;<br />
Algorithm.KeySize = 256;<br />
Algorithm.Padding = PaddingMode.PKCS7;<br />
<br />
<br />
using (MemoryStream memStream = new MemoryStream())<br />
{<br />
using (ICryptoTransform EncryptorDecryptor = Algorithm.CreateEncryptor(key, iv))<br />
{<br />
using (CryptoStream crStream = new CryptoStream(memStream, EncryptorDecryptor, CryptoStreamMode.Write))<br />
{<br />
UTF8Encoding utf8enc = new UTF8Encoding();<br />
enc_byte = utf8enc.GetBytes(s);<br />
crStream.Write(enc_byte, 0, enc_byte.Length);<br />
crStream.FlushFinalBlock();<br />
}<br />
}<br />
}<br />
<br />
<br />
enc_str = Convert.ToBase64String(enc_byte);<br />
return enc_str;<br />
<br />
}<br />
<br />
<br />
<br />
public string Decrypt(string s)<br />
{<br />
string dec_str;<br />
byte[] decrepted_byte;<br />
<br />
Algorithm = new RijndaelManaged();<br />
<br />
Algorithm.BlockSize = 256;<br />
Algorithm.KeySize = 256;<br />
Algorithm.Padding = PaddingMode.PKCS7;<br />
<br />
<br />
byte[] dec_byte = new byte[s.Length];<br />
dec_byte = Convert.FromBase64String(s);<br />
decrepted_byte = new byte[dec_byte.Length];<br />
<br />
using (MemoryStream memStream = new MemoryStream(dec_byte))<br />
{<br />
using (ICryptoTransform EncryptorDecryptor = Algorithm.CreateDecryptor(key, iv))<br />
{<br />
using (CryptoStream crStream = new CryptoStream(memStream, EncryptorDecryptor, CryptoStreamMode.Read))<br />
{<br />
crStream.Read(decrepted_byte, 0, decrepted_byte.Length);<br />
}<br />
}<br />
}<br />
<br />
UTF8Encoding utf8enc = new UTF8Encoding();<br />
dec_str = utf8enc.GetString(decrepted_byte);<br />
return dec_str;<br />
<br />
}<br />
<br />
}<br />
}<br />
so, you see none of the answers could help me!
|
|
|
|
|
Roshanakak wrote: none of the answers could help me!
because you gave fictitious code to start with.
|
|
|
|
|
|
How m i going to unit testing this kind of function?
plz help.
private void saverecord()
{
OleDbConnection savecon = new OleDbConnection(constring);
OleDbCommand savecom = new OleDbCommand("insert into Employee_Details values (?,?,?)", savecon);
OleDbParameter param;
param = savecom.Parameters.Add("@empcode", OleDbType.VarChar, 10);
param.Value = txtcode.Text;
param = savecom.Parameters.Add("@empname", OleDbType.VarChar, 25);
param.Value = txtname.Text;
param = savecom.Parameters.Add("@empjoin", OleDbType.Date);
param.Value = DateTime.Now.ToShortDateString();
savecon.Open();
int rows = savecom.ExecuteNonQuery();
MessageBox.Show(rows.ToString() + "rows affected");
btnref.PerformClick();
savecon.Close();
}
[TestMethod()]
public void saverecordTest()
{
Form1_Accessor target = new Form1_Accessor(); // TODO: Initialize to an appropriate value
target.saverecord();
//Assert.Inconclusive("A method that does not return a value cannot be verified.");
}
|
|
|
|
|
Best way would be to seperate your GUI (form) from your dataaccess. This will give you the opportunity to test GUI and data-access seperately.
For GUI testing use mocks to simulate the data-access. Testing the data-access is simple, just call your saveRecord-Method and try to read the record afterwards (don't forget to cleanup afterwards).
Regards
Sebastian
|
|
|
|