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 kumarPosted Feb 27, 2010, 12:39 AM
i am uploading that here,change the source path in the connection string and work on that
mark the answer if it helps you
Sam HobbsPosted Feb 28, 2010, 1:31 PM
GustavoPosted Feb 28, 2010, 3:46 AM
Thanks...
kiran kumarPosted Feb 28, 2010, 3:45 AM
GustavoPosted Feb 28, 2010, 3:41 AM
I'm going to use the Microsoft SQL.
kiran kumarPosted Feb 28, 2010, 3:39 AM
GustavoPosted Feb 28, 2010, 3:28 AM
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 kumarPosted Feb 28, 2010, 3:25 AM
GustavoPosted Feb 28, 2010, 3:23 AM
I did... the above post where you included the program zipped. Did I do it correctly?
kiran kumarPosted Feb 28, 2010, 3:21 AM
GustavoPosted Feb 28, 2010, 3:19 AM
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 kumarPosted Feb 28, 2010, 3:15 AM
GustavoPosted Feb 28, 2010, 2:55 AM
Thanks for helping.
Here is my file and the program that I changed.
kiran kumarPosted Feb 28, 2010, 1:34 AM
i will rectify if there is any problem
GustavoPosted Feb 28, 2010, 12:31 AM
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 kumarPosted Feb 27, 2010, 11:05 PM
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
kiran kumarPosted Feb 27, 2010, 10:52 PM
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
GustavoPosted Feb 27, 2010, 8:31 PM
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.
theLizardPosted Feb 27, 2010, 3:53 PM
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.
GustavoPosted Feb 27, 2010, 9:51 AM
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";
GustavoPosted Feb 26, 2010, 4:37 PM
I answered my own question.
I was using "ProfileUser_ID" and I shlould of used "ColumnUser_ID".