Jump to content
Xtreme .Net Talk

TripleB

Avatar/Signature
  • Posts

    38
  • Joined

  • Last visited

About TripleB

  • Birthday 02/10/1982

Personal Information

  • Occupation
    Operation Center Engineer
  • .NET Preferred Language
    C#

TripleB's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. What is the error that you get? Maybe try to step trough the code to see if he does the check correctly realized something, if you use wildcards that you have to you LIKE and not = in your SQL statement ... if I am not mistaking. Greetz,
  2. Hey, Can't you just do this. If the textbox is empty than the value to search is by default % (wildcard). Regards.
  3. This means that you are using an object that is not instanciated, do you have some code in the close event of the form? You just have to find where the error is thrown. From there on if you give the code I could give you some pointers, But the bottom line is that you are trying to use something that has not been instanciated (ex Form frmExample = new Form() ) Greetz
  4. Hi, It is not realy weird, it is an entire different error, it says that you are assigning something (your selecteditem) to something that is not compatible with that (your datarowview) It even suggests the answer (are you missing a cast). So your first problem is solved, but you are now facing another one. Greetz
  5. This is the code I used, nothing to fancy just using a timer to call the webservice every 8000, and according to the result of the parsing I call another webservice to send the message. #pragma once using namespace System; using namespace System::Collections; using namespace System::ServiceProcess; using namespace System::ComponentModel; using namespace System:: Diagnostics; using namespace GsoapSMS; using namespace MessagingSystem; using namespace System::Text; namespace CheckSMS { /// <summary> /// Summary for CheckSMSWinService /// </summary> /// /// WARNING: If you change the name of this class, you will need to change the /// 'Resource File Name' property for the managed resource compiler tool /// associated with all .resx files this class depends on. Otherwise, /// the designers will not be able to interact properly with localized /// resources associated with this form. public __gc class CheckSMSWinService : public System::ServiceProcess::ServiceBase { public: CheckSMSWinService() { InitializeComponent(); } /// <summary> /// Clean up any resources being used. /// </summary> void Dispose(bool disposing) { if (disposing && components) { components->Dispose(); } __super:: Dispose(disposing); } private: bool stopping; int loopsleep; //milliseconds Threading::Thread* servicethread; private: System::Timers::Timer * tmrCheck; sms *LocalSMS; protected: /// <summary> /// Set things in motion so your service can do its work. /// </summary> void OnStart(String* args[]) { Threading::ThreadStart* threadStart = new Threading::ThreadStart(this,mainLoop); servicethread = new Threading::Thread(threadStart); servicethread->Start(); } void mainLoop() { loopsleep = 10000; //milliseconds stopping = false; LocalSMS = new sms(); ArrayList *list = new ArrayList(); while (!stopping) { if(tmrCheck->Enabled == false) tmrCheck->Enabled = true; Threading::Thread::Sleep(loopsleep); } } void ParseMessage(SmsInfo* info) { if(info->Message->StartsWith("[u]")) { SyntraWebService *msging = new SyntraWebService(); StringBuilder *strBuild = new StringBuilder(); System::Object* list[] = msging->AllContacts(); for(int i=0;i<list->Count;i++) { strBuild->Append(list[i]->ToString()); if(i < list->Count -1) strBuild->Append(","); } LocalSMS->SMSSend(info->Number->ToString(),strBuild->ToString()); } } /// <summary> /// Stop this service. /// </summary> void OnStop() { stopping = true; } private: /// <summary> /// Required designer variable. /// </summary> System::ComponentModel::Container *components; /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> void InitializeComponent(void) { this->tmrCheck = new System::Timers::Timer(); (__try_cast<System::ComponentModel::ISupportInitialize * >(this->tmrCheck))->BeginInit(); // // tmrCheck // this->tmrCheck->Enabled = true; this->tmrCheck->Interval = 8000; this->tmrCheck->Elapsed += new System::Timers::ElapsedEventHandler(this, tmrCheck_Elapsed); // // CheckSMSWinService // this->CanPauseAndContinue = true; this->ServiceName = S"CheckSMS"; (__try_cast<System::ComponentModel::ISupportInitialize * >(this->tmrCheck))->EndInit(); } private: System::Void tmrCheck_Elapsed(System::Object * sender, System::Timers::ElapsedEventArgs * e) { SmsInfo* SmsRetval; do { if((SmsRetval = LocalSMS->SMSCheck())!= 0) { ParseMessage(SmsRetval); } }while(SmsRetval->NbrofSms > 0); } }; } greetz
  6. I had the same problem in the same situation, also tried to send sms through webservice, but this one was located on a linux server, I am going to look at my project to see how I've solved it, Greetz
  7. Yes it is possible, what exactly are you trying to do?
  8. Not quite sure about what you are trying to do, the code you provided doesn't make much sense. If you have filled your array with the names of the fields of your row, you can easily create all sorts of strings with that, just loop through the items of the arraylist, with a for each loop and append them to a stringbuilder object to the string that you desire. example in C#: 'Create the arraylist ArrayList FieldList = new ArrayList(); StringBuilder strQuery = new StringBuilder(); 'Add items to it FieldList.Add("Item1"); FieldList.Add("Item2"); FieldList.Add("Item3"); foreach string strItem in FieldList { strQuery.Append("This is the item: "); strQuery.Append(strItem); } MessageBox.Show(strQuery.ToString()); This will add item1..3 to the arraylist then append all these items to the stringbuilder object and show a messagebox showing the concatinated string. In this manner you can create everything you want, from sentenses to queries to whatever. Maybe this will help, but i would suggest to clarify you question so we can offer you a better explenation or solution. Greetz
  9. In my opinion you can't, if you read the msdn documentation you will see that the IDatareader interface meaning also the oledbdatareader and I quote: "Provides a means of reading one or more forward-only streams of result sets obtained by executing a command at a data source, and is implemented by .NET Framework data providers that access relational databases." So I think it is not possible to do so, I would recommend storing your query in a DATASET which gives you more options in that directions. Greetz
  10. the class you should use is System.IO.Directory The methods are GetLogicalDrives() retrieving all the disks GetDirectories() retrieving all directories GetFiles() retrieving all files They all return an array of strings containing the names of the items. with this information you can build what you want, using these Controls the treeview and the listview. This should get you started, If you still need some help please let me know Greetz
  11. You can use the colordialog Colordialog Greetz
  12. Ok, the reason my code was so slow was actually my own dumb fault, I opened and closed the connection everytime I added an record so seriously perfomance drop, aftering altering this method in first adding the sql string to an string array, and than executing them all in 1 open connection time was divided by 45 so i would say thats a reasonable improvement :). I can now add approx 250 records in 1,52 sec whats ok for me, i am still going to try an other approach with first writing it to csv and then import that file into excel, the writing of the csv takes only 0.25 sec so unless importing it in excel takes forever it might just be a bit faster I'll post my findings back here, Greetz
  13. Hello all, I have written a class that exports all the rows of a table in a dataset to an excel file, I use an oledb connection to do this. now it works no problem but I wonder if I can speed it up, this is where you specialist come in, this is my code this one creates the excel file and the first cells ( headers ) try { if(System.IO.File.Exists(System.IO.Path.GetFullPath(_FileName))) System.IO.File.Delete(System.IO.Path.GetFullPath(_FileName)); DT = _ds.Tables[0]; StringBuilder CreateTable = new StringBuilder("CREATE TABLE "); CreateTable.Append(_ds.DataSetName); CreateTable.Append(" ("); foreach(DataColumn col in DT.Columns) { CreateTable.Append(col.ColumnName); CreateTable.Append(" " + DBDataType(col.DataType,col.MaxLength) + ", "); } CreateTable.Replace(",",")",CreateTable.Length - 2,1); CreateTable.Append(";"); Console.WriteLine(CreateTable.ToString()); Console.WriteLine( BVQuery.Excel(_FileName).ExecuteNonQuery(CreateTable.ToString()) ); return true; } catch(OleDbException) { return false; } this inserts the records into the exsisting excel file. StringBuilder InsertString = new StringBuilder(); foreach(DataRow row in DT.Rows) { if(InsertString.Length > 0) InsertString.Remove(0,InsertString.Length); InsertString.Append("INSERT INTO "); InsertString.Append(_ds.DataSetName); InsertString.Append(" ("); foreach(DataColumn col in DT.Columns) { InsertString.Append(col.ColumnName + ","); } InsertString.Replace(",",")",InsertString.Length - 1,1); InsertString.Append(" VALUES ("); for(int i = 0;i<row.ItemArray.Length;i++) { InsertString.Append("'" + row.ItemArray.GetValue(i).ToString() + "',"); } InsertString.Replace(",",")",InsertString.Length -1,1); InsertString.Append(";"); Console.WriteLine(InsertString.ToString()); Console.WriteLine(BVQuery.Excel(_FileName).ExecuteNonQuery(InsertString.ToString())); } the BVQuery.excel.executenonquery just executes the sql string given on a oledb connection to the excel file All comment apreciated Greetz to you all
×
×
  • Create New...