|
First of all you will need to open a connection to the database. Depending on which db you want to write to choose one of the providers coming with the framework (OleDb, ODBC...). If you need it fast you'll probably have to test them.
If its possible I would define a stored procedure in the database. Otherwise you will have to make a parameterized query. Once this is done the reading can begin.
You will now need a FileStream to open the file and read it line by line. Depending on the format you will have to split each line some way and fill in the parameters to your query. Execute it and go fopr the next line.
Thats it.
|
|
|
|
|
Thanks
But, would u tell me more about parameterized query and give me some resources or examples.
And another Q, do u prefer to insert the data line by line or first read as much as I can from the file and the insert them together.
|
|
|
|
|
1. Have a look here. Its in VB.Net and originally meant for ASP. But the same techniques apply for C# windows applications. The sample there could give you a good start. As you want to load data into the database and not read the only really difference is that you will have to use ExecuteQuery instead of ExecuteReader.
2. When using parameterized queries you will have to insert the data line by line. Thus there is no real reason to load more than line at a time into memory. In order to increase you could read your data in one thread (storing many lines in memory) and writing them to the database in another thread. This could improve performance in certain situations, but is also a bit advanced, so you probably should stick to the line by line handling.
|
|
|
|
|
If you are going to work with SQL Server The fastest way will be to use DTS.
Uri
|
|
|
|
|
|
DTS is a part of the SQL Server and it states for: Data Transformation Services.
It is particularly handy when you want to perform a task of transferring a data from text files, excels or other databases. DTS will be significantly faster than other program under assumption that there is no special business logic for the data to be transferred (Conversion of data isn’t considered to be a special business logic and can be easily done by the DTS).
Hope it helps,
|
|
|
|
|
hi,
i'm a developer in a consultant company. They asked me do a ( blog Page ) in ASP.net but the idea of programming blogs in dot net is new to me. so can any body helps me and guide me how to do this? any wizards ? code examples ? any thing any thing that can helps me thanks ..
|
|
|
|
|
*hides a smile* hehe, it's not that difficult (although this depends on what you exactly want) So let me ask you: What exactly do you want to be in the blogsystem?
Here's an example of an open source PHP blogsystem. http://www.bblog.com/[^]
There's also a .NET blogging system that has a workspace on gotdotnet
http://www.gotdotnet.com/workspaces/workspace.aspx?ID=E99FCCB3-1A8C-42B5-90EE-348F6B77C407[^]
All I can say is: Get a basic Idea and start working from there. If you know what you want, you can ask more specific questions on how to solve parts of the problem
WM.
What about weapons of mass-construction?
|
|
|
|
|
A blog is a pretty basic sort of site - what do you normally do there ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
Is it passible to overload a enum datatyp?
regards,
hasan
Mohamed Hasan is usally called as Hasan. He is very much interested in C++ programming . He slowly picking up .NET programming. He done his Bachler degree in Arumugam Pillai Seethai Ammal college Thiruppathur. and Master degree in MK university College.
Contact him at: hasansheik@hotmail.com
hasansheik@yahoo.co.in
hasansheik@lycos.com
|
|
|
|
|
Are you sure you know what overloading means?
No its not possible and I dont even know what exactly you mean
|
|
|
|
|
Overloading enums? Overloading applies to functions, defining functions with the same name but with different signatures.
Maybe you meant extending enums by deriving from them? Nope, that's not possible.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Which is much faster in retrieving data form sql or xml ?,
And what is the advantages of each ?
|
|
|
|
|
The question is somehow wrong.
XML is a way to format data so that they can easily be read in a standarized way. SQL is a language to retrieve data from databases. So they are targeting completely different things. There are even database where an SQL query works on or even returns XML.
The advantage of XML is that its a standarized way to format data and libraries exist for nearly every programming language to easily read them. Because it is generally file based and needs many string operations it is relatively slow (compared to other formats).
With SQL you have a language at hand where you describe what data you want to get from a datasource. The advantage is that about every database allows SQL queries and the syntax is nearly the same on all of them. But it doesnt provide any way to access the database. For that you'll need some libraries which transfer your commands to the database and retrieve the data so you can access it. In .Net this is done by various providers (e.g. for OleDb, ODBC, Oracle...). Depending on which one you choose this access is generally by far faster than XML (at least when it comes to large amounts of data).
|
|
|
|
|
OK,That helps me ,Thanks a lot.
|
|
|
|
|
Hello everybody,
I'm sure many of you have noticed that the doubleclick event of a datagrid object does not respond when clicking on a cell.
I googled and found that it's because the first click selects the textbox and the second click raises the Click event of that textbox.
now the obvious question is: how can I make the doubleclick event work? is there a way to make the datagrid control less complicated, or use a simple class of it's own instead of a textbox?
|
|
|
|
|
hi,
you can call the grid's double click event whithin the textbox's double click event.
that's all
Mohamed Hasan is usally called as Hasan. He is very much interested in C++ programming . He slowly picking up .NET programming. He done his Bachler degree in Arumugam Pillai Seethai Ammal college Thiruppathur. and Master degree in MK university College.
Contact him at: hasansheik@hotmail.com
hasansheik@yahoo.co.in
hasansheik@lycos.com
|
|
|
|
|
Hello Hassan,
right I could point the two at the same procedure, but this will enforce a triple click to raise the double click event(1click =select +2clicks=dblckick) which is not what I want to achieve
|
|
|
|
|
Hi
I downloded motion detection in vedio from this link
http://www.codeproject.com/csharp/Motion_Detection.asp
But i want to adjust the motion detection sensitivity means if set sensitivity to large then it will detect the motion only in large scale,if it is set to small scale then it will detect small motion also.
Please give me solution related to that.
Otherwise give me an idea where can i adjust detection rate.
Please send me solution to mail2mamathak@yahoo.com
Thanks in advance.
Mmatha
|
|
|
|
|
Hi
I am getting difficulty on making RAS Application Using C# for desktop application.
I have two computer which are connected on modem thr telephone.
Both computers are not on network.
When i dial the other computers using dial up it starts calling and after registering its get connected on LAN.
I have to make that application in C#.
Actually my application is to connect remote computers using DIal up and after that it will connect with database MySql . I only need to write code for Dial so that remote computers can be made on LAN. Once its on LAN i can do maipulatiuon on database
Anyone can give me idea or program
Regards
sanjeev
Regards,
sanjeev
|
|
|
|
|
I create one appl. in C# and now i wanna insert string-text from textboxes to datagrid but it shows me one error. here is the code which i did write: The code is for InsertButton.I am not using storedProcedure.
string ins = "INSERT INTO tabela(Column1,Column2,Column3,Columns4)VALUES ("+
"'"+ this.txtColumn1.Text + "'" + ","+
"'" + this.txtColumn2.Text + "'" + "," +
"'" + this.txtColumn3.Text + "'" + "," +
"'" + this.txtColumns4.Text + ")";
SqlConnection stringuu = new SqlConnection( "workstation id=mypc;packet size=4096;integrated security=SSPI;data source=mydatabase;persist security info=False;initial catalog=");
SqlDataAdapter daa = new SqlDataAdapter();
DataSet dss = new DataSet();
daa.Fill(dss,"table");
SqlCommand inscomm= new SqlCommand(shtoje,stringuu);
stringuu.Open();
inscomm.ExecuteNonQuery();
stringuu.Close();
can somebody tell me where is mistake???
|
|
|
|
|
seferi wrote:
can somebody tell me where is mistake???
1. "'" is superfluous, you could just put them in with the other text.
2. None of your variable names are remotely meaningful, in your code or ( far worse ) in your database
3. You didn't tell us what the error message was
4. Why aren't you using stored procedures, if you can ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
seferi wrote:
string ins = "INSERT INTO tabela(Column1,Column2,Column3,Columns4)VALUES ("+
"'"+ this.txtColumn1.Text + "'" + ","+
"'" + this.txtColumn2.Text + "'" + "," +
"'" + this.txtColumn3.Text + "'" + "," +
"'" + this.txtColumns4.Text + ")";
Your first problem comes after your this.txtColumns4.Text. You forgot the ending "'".
Like I said, that is your first problem and actually your smallest. Your biggest problem is that you are open for Sql Injection errors. You should really be using paramterized queries to prevent this.
Please see http://www.codeproject.com/useritems/SqlWrapper.asp[this]
|
|
|
|
|
why the windows form can't be debugging when i tried to compiled in and there's no event handling??
|
|
|
|
|
Can you explain much more ?
|
|
|
|