Hello:
What I have found is that the code is suppose to be something like the following: (I think)
dataGridViewIP_Login.Rows[1].Cells["ProfileUser_ID"].Value = "aaaa"; // The '1' will be replaced with the row value later.
But it seems that it does not add the "aaaa" into the grid.
A few days ago, I was reading in a txt(csv) file and using it. Now I would like to load it into a dataGridView...use it and then write it back out to the txt(csv) file.I would like to use a database for this stuff I am doing, but I cant. Its a control record that I use to validate if the user can (be allowed) to the databases.
If anyone knows where I can get a sample code program, I appreciate it.
Loading

kiran kumarRank #3,110 · 461 reputationPosted Feb 26, 2010, 7:39 PM EST
i am uploading that here,change the source path in the connection string and work on that
mark the answer if it helps you
GustavoRank #1,990 · 732 reputationPosted Feb 26, 2010, 11:37 AM EST
I answered my own question.
I was using "ProfileUser_ID" and I shlould of used "ColumnUser_ID".
GustavoRank #1,990 · 732 reputationPosted Feb 27, 2010, 4:51 AM EST
Thanks... I will implement it into my program and get back to you on the progress. Seems simple, I hope I can get it to work.
Except that long line:
string querystring="Driver={Microsoft Text Driver (*.txt; *.csv)};defaultdir=C:\\Documents and Settings\\kirankumar\\Desktop\\kumar;driverid=27;fil=text;filedsn=C:\\Documents and Settings\\kirankumar\\Desktop\\kumar\\test.csv.dsn;maxbuffersize=2048;maxscanrows=8;pagetimeout=5;safetransactions=0;threads=3;uid=admin;usercommitsync=Yes";
theLizardRank #1,079 · 1.8K reputationPosted Feb 27, 2010, 10:53 AM EST
It is entirely up-to you but i have attached a zip file "formsManagement" that addresses some of the questions you have asked on this forum.
How to load a datagrid with csv's, edit and save CSV's and MDI forms management.
There are NO data type controls need to load, save or edit csv's
eg load,
//-------------------------------------------------------------------------------------------------------
public void openFile()
{
string[] lines = new string[0];
if(dlgOpen.ShowDialog() == DialogResult.OK)
{
dirty = false;
if(this.Text == dlgOpen.FileName)
return;
this.Text = dlgOpen.FileName;
lineElement[] e = new lineElement[0];
DataGridViewRow dgr = null;
DataGridViewTextBoxCell txt = null;
StreamReader sr = new StreamReader(dlgOpen.FileName);
string l = "";
while((l = sr.ReadLine()) != null)
{
Array.Resize(ref e, e.Length +1);
e[e.Length-1] = new lineElement();
Array.Resize(ref e[e.Length-1].elements, getCount(",", l));
e[e.Length-1].elements = l.Split(new char[] {','});
dgr = new DataGridViewRow();
for(int i = 0; i < e[e.Length-1].elements.Length; i++)
{
txt = new DataGridViewTextBoxCell();
txt.Value = e[e.Length-1].elements[i];
dgr.Cells.Add(txt);
}
dg.Rows.Add(dgr);
}
}
}
There is also no need for connection strings and you wont need tope that this will work, it does, you can simply put the csv form into your project compile and it will run...
You may also find the forms management (MDI) side interesting, there is an exe in zip.
GustavoRank #1,990 · 732 reputationPosted Feb 27, 2010, 3:31 PM EST
I tried the program you gave me. I can not get it to work. I changed the: string querystring="Driver={Microsoft Text Driver (*.txt; *.csv)};defaultdir=C:\\Documents and Settings\\kirankumar\\Desktop\\kumar;driverid=27;fil=text;filedsn=C:\\Documents and Settings\\kirankumar\\Desktop\\kumar\\test.csv.dsn;maxbuffersize=2048;maxscanrows=8;pagetimeout=5;safetransactions=0;threads=3;uid=admin;usercommitsync=Yes";
But I must of not chnaged it correctly.
kiran kumarRank #3,110 · 461 reputationPosted Feb 27, 2010, 5:52 PM EST
string querystring="Driver={Microsoft Text Driver (*.txt; *.csv)};defaultdir=C:\\Documents and Settings\\kirankumar\\Desktop\\kumar;driverid=27;fil=text;filedsn=C:\\Documents and Settings\\kirankumar\\Desktop\\kumar\\test.csv.dsn;maxbuffersize=2048;maxscanrows=8;pagetimeout=5;safetransactions=0;threads=3;uid=admin;usercommitsync=Yes";
change the source path,put the path of your csv file
mark the answer if it helps you
kiran kumarRank #3,110 · 461 reputationPosted Feb 27, 2010, 6:05 PM EST
do one thing
go to tools->connect to database->change->microsoft odbc datasource->use connection string->click build->file source->new->Microsoft access text driver(*.txt,*.csv)->next->browse->save as type->all files->locate your csv file->next->finish.
then go to server explorer click on your database and go to properties you will find connection string copy that and place it in your program.(replace all '\' with '\\')
mark the answer if it helps you
GustavoRank #1,990 · 732 reputationPosted Feb 27, 2010, 7:31 PM EST
Thanks... you instructions where really step-by-step... its GREAT.
However... I did it. I can see the file in the server explorer and access it with no problem. But, the program does not populate the grid.
kiran kumarRank #3,110 · 461 reputationPosted Feb 27, 2010, 8:34 PM EST
i will rectify if there is any problem
GustavoRank #1,990 · 732 reputationPosted Feb 27, 2010, 9:55 PM EST
Thanks for helping.
Here is my file and the program that I changed.
kiran kumarRank #3,110 · 461 reputationPosted Feb 27, 2010, 10:15 PM EST
GustavoRank #1,990 · 732 reputationPosted Feb 27, 2010, 10:19 PM EST
Thanks... so, it must be something on my machine. Interesting.
LOL... I just did a check... It does not run on x64... I had to change it to x86... Thanks for your help.
kiran kumarRank #3,110 · 461 reputationPosted Feb 27, 2010, 10:21 PM EST
GustavoRank #1,990 · 732 reputationPosted Feb 27, 2010, 10:23 PM EST
I did... the above post where you included the program zipped. Did I do it correctly?
kiran kumarRank #3,110 · 461 reputationPosted Feb 27, 2010, 10:25 PM EST
GustavoRank #1,990 · 732 reputationPosted Feb 27, 2010, 10:28 PM EST
Yes... Now I have to implement the save function and then I am done. The I have to test the program fully.
My next part is to use the data that they pick and connect to a real database. With the step-by-step instructions you gave me before, I should be able to create the connection string for the database.
kiran kumarRank #3,110 · 461 reputationPosted Feb 27, 2010, 10:39 PM EST
GustavoRank #1,990 · 732 reputationPosted Feb 27, 2010, 10:41 PM EST
I'm going to use the Microsoft SQL.
kiran kumarRank #3,110 · 461 reputationPosted Feb 27, 2010, 10:45 PM EST
GustavoRank #1,990 · 732 reputationPosted Feb 27, 2010, 10:46 PM EST
Thanks...
Sam HobbsRank #107 · 20.5K reputationPosted Feb 28, 2010, 8:31 AM EST