|
Okay,
Sorry for my poor english.
I have sucessfully imported a CSV file into a DataSet .
I need to execute an SQL statement using COUNT , GROUP BY and ORDER BY . The request is done and works fine. I need to run it in C#.
While the data remain in a DataSet , I would like to know how I can execute the SQL statement on this DataSet?
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
Hi man
here is the Code.
public Dataset GetData()
{
Dataset dsdata = new Dataset();
String Constr = @"User ID=sa;Password=;Database=MyDB; Server =MYSERVER";
SqlConnection con = new SqlConnection(Constr);
SqlCommand cmdselect = new SqlCommand("SELECT toto as X, count(titi)as Y from MY_TABLE GROUP BY X, ORDER BY X");
cmdselect.CommandTimeout = 0 ;
cmdselect.Connection = con;
SqlDataAdapter da = new SqlDataAdapter(cmdselect);
da.Fill(dsdata);
return dsdata;
}
Tell me if you have Problems (vuyiswamb) Skype
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Hi,
As I said, the data are already in a DataSet loaded in memory from a CSV file and not in a database.
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
ok,
I was showing you, if the data is already in the dataset. then your Dataset will have a name and a datatable, then from the above code.
see , you will end up with a dataset object.
Dim strFileName As String = "MyFile.csv"
Dim strPath As String = "C:\"
Dim strCon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" + strPath + ";Extended
Properties='text;HDR=Yes;FMT=Delimited'"
Dim con As New OleDbConnection(strCon)
Dim cmdGetCsv As New OleDbCommand("SELECT * from " +
strFileName, con)
Dim csvAdapter As New OleDbDataAdapter(cmdGetCsv)
'Dim csvReader As OleDbDataReader
con.Open()
Dim dsCsv As DataSet = New DataSet
csvAdapter.Fill(dsCsv)
you can change your Select statement to your liking.
Hopr this Helps
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Hi,
I have a web service that references the DLL. Inside the DLL I make a connection to a database, and do some data manipulation. However, for some reason I can not establish the connection. (DLL is a COM object).
On the other hand if I just use a simple windows forms application and reference the same DLL, I connect with no problems.
It seems that I am missing some settings or something.
Really need help.
Thank you!
|
|
|
|
|
What is the error? What exceptions are being thrown?
|
|
|
|
|
The exception that it's throwing is the Time out exception.
Thank you
modified on Monday, June 9, 2008 10:12 AM
|
|
|
|
|
Hi zaboboa
If you can just post your code , it will be easy for us to help you
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Hi!
Unfortunatelly I have no control over the DLL that I am using.
The method in DLL will return the ADO connection object.
It's working fine when I reference it from Windows Form Application (connection object is returned), and not fine (get the Timeout Exception) when referenced from Web Service running on my local machine.
So, I guess my question is what is the difference in referencing components from Web Service and Windows Form application?
Thank you.
|
|
|
|
|
hi man
I understand your Problem. What you receive is the timeout in the Command object. I hear you say you have no Access to the DLL code. So that means you have little to do with that Problem. i will tell you what did the person who write the DLL missed.
CommandObject.CommandTimeout = 0;
Atleast microst Recomend it, that means it is infinite.There Shouldnt be a Difference.
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Thanks.
How come it works when I call it from a Windows Form Application?
|
|
|
|
|
Hi
Remember there is a Difference Between Web and Windows.
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
hi
how to use TextEffectFormat from Microsoft.Office.Interop.Word ?
thnx
|
|
|
|
|
I need to call a function just before ComboBox.SelectedIndexChanged event is fired.
The idea is to take screen-shot of Windows Form (having a ComboBox) showing last-selected ComboBox item when the user selects another item in the ComboBox.
Please let me know if of an event which is called before SelectedIndexChanged (i.e before selected value changes).
May be an event like BeforeSelectionIndexChanged.
|
|
|
|
|
Madandu wrote: May be an event like BeforeSelectionIndexChanged.
If there is the general convention is to using the -ing ending.
BlahChanging - fired before an action is taken
BlahChanged - fired after an action is taken.
|
|
|
|
|
Colin Angus Mackay wrote: BlahChanging - fired before an action is taken
But there is no SelectedIndexChanging so i suggest you create a control that inherits from ComboBox and override OnClick to raise a SelectedIndexChanging.
Or, keep an image of the combobox to use it when next SelectedIndexChanged.
Eslam Afifi
|
|
|
|
|
Hi friend i want to show message box just like in msn when new user Login or email received. For my application so that at any new change my software tell the user about change at the message box just like MSN
wasim khan
|
|
|
|
|
|
|
|
Hi Everybody,
I'm strucking with this task from last 2 weeks,
is project setup (the user has no .net frame work ,sql server etc..,we have to put ".exe" files along with our project Setup file ,How can I do this,I'm sending my steup fail details ".txt file" also) , and we are using C# 2008 Express Edition,i tried this in TragetSystem,i got total 58 errors ,but i'm sending some error Error Messages.
Could u Please Help me.
Error Details:
1:The install location for prerequisites has not been set to 'component vendor's web site' and the file 'WindowsInstaller3_1\WindowsInstaller-KB893803-v2-x86.exe' in item 'Windows Installer 3.1' can not be located on disk
2:The install location for prerequisites has not been set to 'component vendor's web site' and the file 'DotNetFX35\dotNetFX20\aspnet.msp' in item '.NET Framework 3.5' can not be located on disk. See Help for more information.
3:The install location for prerequisites has not been set to 'component vendor's web site' and the file 'DotNetFX35\dotNetFX20\aspnet_64.msp' in item '.NET Framework 3.5' can not be located on disk. See Help for more information
4:The install location for prerequisites has not been set to 'component vendor's web site' and the file 'SqlExpress\sqlexpr32.exe' in item 'SQL Server 2005 Express Edition SP2 (x86)' can not be located on disk. See Help for more information.
etc..................,
|
|
|
|
|
Good Afternoon my Friend
Firstly when you Create a Setup File in VS, you cannot Automatically install .NET Framework, and that means your users will not be able to install your msi file , because it need the framework installed First. Now one thing that you can do, is in your Installation Disk , just include the Framework, because you cannot install the Framework simultanously with your Application. from oour Errors , i see it complains about (prerequisites) and means the .NET Framework is not installed.
Hope it Helps
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
hi all,,, How i insert ListBox items to Array in c#..?
CheeN
|
|
|
|
|
sacr83,
Does this help?
object[] listBoxObjects = new object[listBox.Items.Count];
listBox.Items.CopyTo(listBoxObjects, 0);
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
I have to say - this is easily found using google, or even MSDN. Try working it out yourself instead of relying on other people to do your coding for you.
string[] listItems = new string[this.listbox.items.count];
for (int i = 0; i < this.listbox.Items.count; i++)
{
listItems[i] = this.listbox.Items[i];
}
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|