C Sharp :: Opening And Importing Multiple Files Into DataGridView / Database
Mar 29, 2013
I'm trying to add a function now that lets the user open 1 or more files and import them to the database and dataGridView. Now the way it is now (should) work. But when it has finished with FILE1, it won't add FILE2 as it then gives me an error that the Column Date Already exists.
My code is below
private void btnOpenLog_Click(object sender, EventArgs e) {
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "Log Files (*.log)|*.log";
openFileDialog1.Multiselect = true;
[Code] .....
View 12 Replies
ADVERTISEMENT
Jul 12, 2013
I just wanna update my database with one click only.
I do for update my database from datagridview1 but it shows a error like this :
Unhandled exception has occurred in your application . If you click Continue, the application will ignore this error and attempt to continue. If you click Quit,the application will close immediately.
Update requires a valid UpdateCommand when passed DataRow collection with modified rows
Attached Files : WindowsFormsApplication4.zip (127.2 KB)
View 2 Replies
View Related
Feb 22, 2015
I have a program in C#.net. There is a datagridview which shows all the details of the student. Then I add a column to update another column using the value I entered. Means I want to add roll no to student details table while running. I want the code to update it. Is it possible?
View 1 Replies
View Related
Feb 9, 2013
I have patient_table in the database. which contain Id, name ,Image & other fields I have inserted the image in the Byte form in the database.Now i want to display all records in the Datagrid view in windows Form.
i am able to display id & Name & all fields but unable to display the image of a patient in the datagrid view.
I put all the records in the genric list:-
public static List<Personal_Details> AllMembers() {
List<Personal_Details> listMembers = new List<Personal_Details>();
Personal_Details pDetails;
try {
String Constring = ConnectionString.dataBaseConnectionString;
[code]...
i am unable to write the code for displaying the image on data gridview.
I am unable to find the solution for binding the image field in the datagrid view.
View 3 Replies
View Related
Mar 11, 2013
I'm trying to get some more user friendly things in my program done. Now I'm trying to filter by typing in a text box and it filters to what you are typing and shows the entire row.
This is what I currently have:
private void txtFilter_TextChanged(object sender, EventArgs e) {
try {
SQLiteConnection connect = new SQLiteConnection(connString);
connect.Open();
[Code] ....
I get an exception error though:
SQLite error
near "'N'": syntax error
// N is what I started typing to start the filter.
Ok, so I've edited the code now to this:
private void txtFilter_TextChanged(object sender, EventArgs e) // FILTER TODO {
DataView view = new DataView();
SQLiteConnection connect = new SQLiteConnection(connString);
connect.Open();
view.RowFilter = "Channel like '%" + txtFilter.Text + "%'";
}
No more exception errors, just not what I want it to do. It just keeps everything there.
View 10 Replies
View Related
Mar 1, 2013
private String[] GetExcelSheetNames(string excelFile) {
OleDbConnection objConn = null;
SqlConnection objSqlConn = null;
System.Data.DataTable dt = null;
try {
[code].....
Now I can fatch all the excel sheet belongs to the Excel File.But How can I check "If and Only If the sheets are havin Underscore in their name(eg. student_data,teachers_data) then only the data of the sheets will populate in tha data base"
View 2 Replies
View Related
Jun 1, 2013
Ihave a gridview which populated via selected item on my drop down list which I don't have any problem with that. My problem is I am trying to save multiple rows on my gridview into my database, for example I have added 3 items on my gridview which looks like this:
Id | Name
111 | Jack
222 | Nicole
333 | John
Now, I want all that under column Id which is 111, 222 and 333 will be save on my database once I click Save button I am trying the code below but it gives me an error saying "system.data.sqlclient.sqlparameter does not contain a definition for 'Values' and no extension method 'Values' accepting a first argument of type..." :
SqlConnection con = new SqlConnection("Data Source=GATE-PCSQLEXPRESS;Initial Catalog=dbProfile;Integrated Security=True");
SqlCommand cmdd = new SqlCommand("Insert into profile (Id, profile_id)VALUES(@id, @profile_id", con);
foreach (GridViewRow row in GridView1.Rows) {
[Code] .....
My table should be look like this once I am able to save multiple rows from my gridview into my database:
auto_id | Id | profile_id
1 |111 | 101
2 |222 | 101
3 |333 | 101
I am using asp.net with c#.
View 1 Replies
View Related
Nov 29, 2010
I have a tcp client - server implementation running in the same program, on different background worker threads. There will be instances of this program on multiple computers so they can send and receive files between each other. I can send files sequentially between computers using network stream, but how would I send multiple files at the same time from computer A to B.
Sending multiple files over one connection ( socket ) is fine, but having multiple network streams sending data to a client, the client doesn't know which chunk of data is apart of which file ?
View 3 Replies
View Related
Jun 24, 2013
I have the following code which allows me to add the pdf files if I give the exact name and path of the file. But I have multiple pdf files in a folder which I want to add to each cell in the first column. I am having trouble thinking of the logic to have a for loop for a folder which contains the pdf files.
private void button1_Click(object sender, EventArgs e) {
Excel.Application xlApp;
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
xlApp = new Excel.ApplicationClass();
xlWorkBook = xlApp.Workbooks.Add(true);
[Code] ...
But this is very very rough draft. I have say 20 files in the folder pdf with different names(Title). How can I add all the 20 pdf files in the excel sheet?
View 6 Replies
View Related
Oct 15, 2014
I'm in a CIS 143 class which is Introduction to Programming using C++. We've been assigned a lab with little to no detail on how to do the things listed.
The purpose of this lab is to practice the file input and output concepts. For this lab you may assume that the input files exist and contain appropriate data inside of them.
Four separate text files* which contain the following lines, different for each file.
(*: This isn't on the lab, but don't worry about what the name, age, id, and major are. those can be random and I can just change them what they need to be)
Name
Age
Student ID Number
Major
Your program should ask the user which of the four input files they would like to open, and then read the contents from the file. Once the contents have been read in, it should output to both the screen and a file named "output.txt" the four values were read in, arranged as follows:
"Hello <name>! You are a <age> years old <major> student, and your ID number is <ID number>"
Now I am by no means saying "Do it for me". I just need to know how to have a user type file1, file2, file3, or file4, and then have the program open that file, then have the output.txt file arrange the wording into the sentence above.
This is what I have so far and I don't think it is anywhere near correct:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
ifstream inFile;
string file1;
string file2;
[code]....
View 1 Replies
View Related
Sep 10, 2014
I have an idea which i will try to implement in C++,I want to compress file size through making my own numbering system which is 80-based number, I do really want to know whether this even possible ? I learnet that Hexadecimal uses symbols like A, B, C, D, E, F to represent 10,11,12,13,14,15 -- and that's what i want to do to my own numbering system but in a bigger scale .if possible: How can i use C++ to open a file in Hex mode ?
View 6 Replies
View Related
Oct 17, 2012
I want to open a command prompt from a console application in a separate window and write some lines of text in the new command prompt.
In the Below code it is not opening the new cmd and not writing the text...
Here is the code:
public static int Main(string[] args)
{
int retValue = 0;
try
{
ProcessStartInfo MyProcess = new ProcessStartInfo();
MyProcess.FileName = "cmd.exe";
[Code]....
View 1 Replies
View Related
Apr 24, 2013
The code below is used to return a file path.
private string BrowseJournalFile(string startRelativePath)
{
string str = "Journal files (*.log)|*.log|All files (*.*)|*.*";
return PathTools.BrowseFile(startRelativePath, str, this.RootPath);
}
So once I click browse I get something like "E:New Files" But there is this .log file in this folder which I want to automatically store in this path.
Right now I have to click on this .log file and then select open. Is there a way I can directly load the file.I have been trying to use the FileStream but no luck.
View 7 Replies
View Related
Oct 11, 2014
I'm new to c# and i'm using vs 2013 and access database..my i need to do multiple update records after I filtered the records in datagridview
In my database table I have these fields ID(PK/autonumber), EID,Date,Day,Daystatus..
In my form I have a button and it's fucntion is filter by date using bidingsource.fiter and this was the result
EID------Date-----------Day---Daystatus
10175--10/11/2014---sat--------regular
10176--10/11/2014---sat--------regular
10177--10/11/2014---sat--------regular
10178--10/11/2014---sat--------regular
what I want to happen is when I click another button called "Apply to all" I want to Update all the daystatus to "Legal Holiday" of the filtered records..I know how to update one by one using simple update..but I need to do the multiple update..
I tried to make a code but it was updating all the records not the filtered only here's my code:
try {
OleDbCommand command = new OleDbCommand();
connection.Open();
command.Connection = connection;
string query = "SELECT EID From EmployeeTable";
command.CommandText = query;
String a = "Legal Holiday";
[Code] ......
View 1 Replies
View Related
Jul 18, 2014
Recently I tried a project template from infragistics
Infragistics Windows Forms -ProjectManager
every time I open the design form it desply this message.
What should I do to resolve it.
View 3 Replies
View Related
May 27, 2013
I am using C# to build up a application. Otherwise, i have two forms, the first form is frmMaterial and the second form is frmMaterialList. frmMaterial has a textbox to get value from datagridview of frmMaterialList. My code doesn't work. How to get value from datagridview of frmMaterialList into textbox of frmMaterial?
Note: frmMaterial has a button to load frmMaterialList
View 2 Replies
View Related
Sep 13, 2014
I have two table the first is called Imprrests and the second is called ]IprestsPays. There is an Imprest_ID column that is primary key in [icode]Imprests[/code] table and foreign key in ImprestsPays table
Imprests table consists the following columns:
Imprest_ID, Impres_value, Imprest_date, Employee_ID
Where Employee_ID column is primary key in Employees table and foreign key in Imprests table.
ImprestsPays table consists the following columns:
ID, Payment_value, Payment_date, Imprest_ID
My problem is in the buttonadd_click event in Imprsts form.
I want to prevent user from insert any new imprest for employee in Imprests table if employee haven't paid all payments in ImprestsPays table for old imprest...
View 1 Replies
View Related
Oct 20, 2014
How to find getthe textbox value in a datagridview & how to delete it?
View 1 Replies
View Related
Feb 18, 2013
i have 10 column in my datagridview. i want to get whole value from row(which row i'll select). i have this code but it's shows only one cell value,
richtextbox.Text = dataGridView1.CurrentCell.Value.ToString();
View 1 Replies
View Related
May 3, 2012
how to disable selection of 1'st row in dataGridView.
I made it select some other row, but even so when u try to move with arrows on keyboard it'll select 2'nd row(cause 1'st row was selected initially and you can see it's selected on RowHeader-1'st/Left Column)
This is my code for selecting row:
dataGridView1.ClearSelection();
dataGridView1.Rows[BoPrI].Selected = true;
dataGridView1.FirstDisplayedScrollingRowIndex = BoPrI;
BoPrI is int variable that has Index Value
View 6 Replies
View Related
Nov 22, 2012
private void button1_Click(object sender, EventArgs e) {
if (openFileDialog1.ShowDialog() == DialogResult.OK) {
TxtPath.Text = openFileDialog1.FileName;
} string connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+TxtPath.Text+"";
DataSet ds = new DataSet();
[Code] .....
View 1 Replies
View Related
Jan 16, 2014
I am writing a piece of code that requires me to display the last 1000 lines from a multiple text files (log files). FYI, I am running on Linux and using g++.
I have a log file from which - if it contains more than 1000 lines, I need to display the last 1000 lines. However, the log file could get rotated. So, in case where the current log file contains less than 1000 lines, I have to go to older log file and display the remaining. For e.g., if log got rotated and new log file contains 20 lines, I have to display the 980 lines from old log file + 20 from current log files.
What is the best way to do this? Even an outline algorithm will work.
View 6 Replies
View Related
Apr 12, 2012
When I am filling a Application form and save this Application form Entries in database it saved successfully but below Application form in DataGridView How to show only current Entry row; There is not show a previous Entries in DataGridView?
View 1 Replies
View Related
Dec 3, 2012
I have a window form with datagridview,textbox,button and listbox. In datagridview i have added a column. In first row i have given the value like 7000,
second row 2500,
third row 7000,
fourth row 1000,
fifth 1300,
sixth 9000....n number of row:
if i enter 12000 in textbox1 then it will calculate the total in particular rows in datagridview.And the total should be less than 12000 what we have entered the value in textbox1.
The result will display in listbox..
like first greater value is 9000+2500=11500 ,
second greater value 7000+1000+1300=9500,
other third greater value is 7,000.
So i have given a sample code where i cannot get the solution ..
double search;
search = double.Parse(textBox1.Text);
double sum = 0;
for (int i = 0; i < dataGridView1.Rows.Count - 1; i++) {
double se2 = Convert.ToDouble(dataGridView1.Rows[i].Cells[0].Value.ToString());
if (se2 == search) {
[code]....
View 5 Replies
View Related
Sep 14, 2014
I delete rows in datagridview using chcekbox column. I write the following code:
private void btndelpay_Click(object sender, EventArgs e) {
DialogResult dr = MessageBox.Show("delete row", "do you want to delete",
MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
if (dr == DialogResult.Yes)
[Code] ......
my problem is /how to umcheck from rows in datagridview in chechboxes column when the user select dialogResult.NO
View 1 Replies
View Related
Sep 14, 2014
I fetch maxid row to view in datagridview using the following code :
public static DataTable GetMaximpID() {
string strconn = AlShehabi.Properties.Settings.Default.NewSalariesDBConnectionString;
SqlConnection conn = new SqlConnection(strconn);
if (conn.State == ConnectionState.Closed)
[Code] ....
But I want to fetch all rows inserted and view in datagridview.... For example if user insert 4 rows I want to view them in datagridview after insert them using insertbutton_click....
View 2 Replies
View Related