|
PIEBALDconsult wrote:
Maybe try
System.Byte[] myTimestamp = <br />
(System.Byte[]) dr["TimeStamp"] ;
Thank You. This has now been resolved.
Pendin Approval
|
|
|
|
|
Try reading it as a long.
|
|
|
|
|
That ain't gonna fly. (Unless maybe he casts it on the database side first.)
|
|
|
|
|
Hi to all.
I have a strange behaviour in a MDI project. I created a toolstrip with buttons in MDI parent for common operations in all children forms (New, Save and Delete).
In a child form, I have a DataGridView with a CheckBoxColumn and a TextBoxColumn with a list of options to choose by user. If i check some checkbox and I press the Save button in the toolstrip, I can't save any data: all the checkbox returns false value. But if i put a button in the child form and call the same void, all work very well.
Someone can answer why?
Here the code for button in MDI parent:
private void tsbtnSave_Click(object sender, EventArgs e)
{
if (this.ActiveMdiChild is Basic.AnalyzersCylinders) ((Basic.AnalyzersCylinders)this.ActiveMdiChild).Save();
}
Here the code to read the results:
public void Save()
{
foreach (DataGridViewRow dgRow in dgvAnalyzers.Rows)
{
if (dgRow.Cells["CheckedItem"].Value != null)
{
if ((bool)dgRow.Cells["CheckedItem"].Value)
{
}
else
{
}
}
}
}
And, obviously, the code for the button in Child form call the same Save() void.
|
|
|
|
|
If you put a breakpoint in the save routine and execute your application does it go to debug when you click on the save button?
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Yes. In the save routine I see the checkedbox items values... but when I press the button in MDI parent, this values are always false, if I press the button in the child form, the values passes in the correct way.
|
|
|
|
|
Hello
Is there a way to extract some values from an XML node using the XmlPathNavigator ?
I need to extrat information from a XML file. I was first trying to use an XmlTextReader but the pure sequential access seeme a bit tedious to handle
So I was trying to use the XpathDocument
I use a XPathNavigator to browse each node of my document (see code below)
But for each product I just need to extract a few information
- Brand
- Model
- ID
(there are a lot of other unneeded information)
Is it possible to do that with the XpathNavigator ?
Or do I need another approach ?
Obviously I can write my own parser but I can't believe that there is no simple way with standard classes ?
Thanks for any help !
XPathDocument xmldoc = new XPathDocument(p);
XPathNavigator nav = xmldoc.CreateNavigator();
int j = 0;
foreach (XPathNavigator product in nav.Select("liste/mobile"))
{
j++;
}
|
|
|
|
|
Probably, but I've never used one. I use an XmlDocument; the SelectNodes and SelectSingleNode methods use XPath.
|
|
|
|
|
Thanks
I finaly found some solution
The first think to care is also the granularity
In my case every product embed a bloc_im node that contains everything
So the first select must be on "liste/product/bloc_im"
I was first doing "liste/product" and it take me a while to understand that first issue !
foreach (XPathNavigator product in nav.Select("liste/product/bloc_im"))
{
string refORF = product.SelectSingleNode("ref").Value;
string IdORF = product.SelectSingleNode("id").Value;
string Brand= product.SelectSingleNode("Brand").Value;
string modele = product.SelectSingleNode("model").Value;
sw.WriteLine("{0}\t{1}\t{2}\t{3}",Id,ref,Brand,modele);
XPathNavigator xNav = product.SelectSingleNode("TACS");
foreach (XPathNavigator xNav1 in xNav.Select("TAC"))
{
string Tac = xNav1.Value;
}
j++;
}
|
|
|
|
|
xmlDoc.SelectSingleNode(liste/mobile); should give the same results.
|
|
|
|
|
I've just discovered LINQ to XML, which makes processing XML files very easy.
You only need two classes (which become available when you have using System.Xml.Linq): XDocument and XElement.
XDocument opens the XML file. XElement is the type of each node in the XML tree. Some of the XElement methods return a nice IEnumerable list that you can process with foreach.
There's a lot more to LINQ to XML, but just these two classes enable you to easily do basic processing.
|
|
|
|
|
I'm not sure WCF is the way I should go here but I'm keen to get to learn a new technology so I thought I should investigate it at least.
We are developing a system in which we need a server-side application (with GUI, so not a Windows service) and several client side applications that communicate with this server side application. All of this happens on the internal network so I figured that TCP binding might be suitable.
The one approach would be to write some TCP/IP server routines on the server-side application and have the clients communicate with it over TCP sockets for which we'd have to implement certain messaging. What I dislike about this approach is the fact that all comms will be request-response type. In other words, the server can only send messages to the client if the client sent a message to the server.
So the possibility of full-duplex comms of WCF seems like a perfect solution. The thing I'm unsure of is whether WCF would allow for a server-side application that has a GUI and allows for user interaction.
I thought I might try getting to know WCF first by writing a small mini system, the sandwich lady notification system, consisting of a "server" side application which runs on the receptionist's computer. A number of other computers in the office then has a client application. The client application can send a message to the server application to subscribe itself to the notifications. When the sandwich lady arrives the receptionist can then open the GUI of the application on her machine and click a button which triggers the app to send a message to all the clients that has subscribed which in turn pops up a notification on the client machine.
I realise there might be better ways to achieve this particular solution but it is a reasonable analogy of what we ultimately want to achieve with out bigger system so I figure I might gain the skills I need if I can figure out how to write this little system.
My question is, could someone tell me please whether WCF is indeed the technology that should be used for this? I have only just started reading up on it but I am getting the impression that with WCF, the server side application will have to take the form of a service, not a desktop application. Could anyone give me some clarity on this please and possibly point me in the right direction for what I'm trying to achieve?
TIA
|
|
|
|
|
You might get a better response by posting your question in the WCF forum[^].
Use the best guess
|
|
|
|
|
Goodness! I didn't even notice there was a forum dedicated to WCF. Thanks for pointing out.
|
|
|
|
|
Hello,
I've just started to programm in C++, using Builder C++. I need to stablish comunication via internet between two computers. I've succed using the ClientSocket Component and the ClientServer but only if the computers are in a local network but not if the computers are in different networks. Here is my code for the server:
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
void __fastcall TForm1::BAbrirClick(TObject *Sender)
{
ServerSocket1->Port=StrToInt(Npuerto->Text);
ServerSocket1->Open();
BAbrir->Enabled=false;
BCerrar->Enabled=true;
BEstado->SimpleText="Servidor Conectado!";
NOnline->Text=IntToStr(ServerSocket1->Socket->ActiveConnections);
BEnviar->Enabled = true;
}
void __fastcall TForm1::BCerrarClick(TObject *Sender)
{
ServerSocket1->Close();
BAbrir->Enabled=true;
BCerrar->Enabled=false;
BEstado->SimpleText="Servidor Cerrado!";
NOnline->Text=IntToStr(ServerSocket1->Socket->ActiveConnections);
BEnviar->Enabled = false;
}
void __fastcall TForm1::ServerSocket1ClientConnect(TObject *Sender,
TCustomWinSocket *Socket)
{
BEstado->SimpleText="Conectado desde "+Socket->RemoteAddress;
NOnline->Text=IntToStr(ServerSocket1->Socket->ActiveConnections);
}
void __fastcall TForm1::ServerSocket1ClientDisconnect(TObject *Sender,
TCustomWinSocket *Socket)
{
NOnline->Text=IntToStr(ServerSocket1->Socket->ActiveConnections-1);
BEstado->SimpleText="Desconectado de "+Socket->RemoteAddress;
}
void __fastcall TForm1::ServerSocket1ClientRead(TObject *Sender,
TCustomWinSocket *Socket)
{
char * buffer;
int len;
AnsiString Mensaje;
int i;
int *tam;
tam = new int;
*tam = Socket->ReceiveLength();
len=Socket->ReceiveBuf(buffer,*tam);
buffer[len]=0;
TTime hora = TTime::CurrentTime();
AnsiString MensajeIn = Socket->RemoteAddress;
MensajeIn += " A las " + TimeToStr(hora) + " Dice" "----->";
ChatBox->Lines->Add(MensajeIn +StrPas(buffer));
BEstado->SimpleText=IntToStr(len)+"Nuevo mensaje entrante!";
Mensaje = StrPas(buffer);
strcpy(buffer,Mensaje.c_str());
for(i=0;i<ServerSocket1->Socket->ActiveConnections;i++)
ServerSocket1->Socket->Connections[i]->SendBuf(buffer,strlen(buffer));
delete[] buffer;
}
void __fastcall TForm1::BEnviarClick(TObject *Sender)
{
char buffer[256];
int i;
AnsiString Mensaje = CampoMensaje->Text;
strcpy(buffer,Mensaje.c_str());
for(i=0;i<ServerSocket1->Socket->ActiveConnections;i++)
ServerSocket1->Socket->Connections[i]->SendBuf(buffer,strlen(buffer));
TTime hora = TTime::CurrentTime();
ChatBox->Lines->Add("Servidor a las " +TimeToStr(hora)
+ " dice----->" + Mensaje);
}
void __fastcall TForm1::LimpiarClick(TObject *Sender)
{
ChatBox->Clear();
}
void __fastcall TForm1::CampoMensajeKeyUp(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if (Key == 13)
TForm1::BEnviarClick(CampoMensaje);
}
void __fastcall TForm1::NpuertoKeyUp(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if (Key == 13)
TForm1::BAbrirClick(Npuerto);
}
void __fastcall TForm1::TcpServer1Accept(TObject *Sender,
TCustomIpClient *ClientSocket)
{
TcpServer1->RemotePort = StrToInt(Npuerto->Text);
TcpServer1->Open();
BAbrir->Enabled=false;
BCerrar->Enabled=true;
BEstado->SimpleText="Servidor Conectado!";
NOnline->Text=IntToStr(ServerSocket1->Socket->ActiveConnections);
BEnviar->Enabled = true;
}
void __fastcall TForm1::TcpServer1CreateHandle(TObject *Sender)
{
NOnline->Text=IntToStr(TcpServer1->Active-1);
BEstado->SimpleText="Desconectado de "+TcpServer1->LocalHostName();
}
How can I implement comunication (a simple chat is enough) between the two computers?
|
|
|
|
|
First of all, good job on starting out with C++. It can be a daunting task, but I've no doubt you'll rise to the challenge. I would like to point out, however, that this is the C# forum and not the C++[^] one. You'll have more luck getting an answer if you ask your question in the correct forum.
|
|
|
|
|
Oh my god, I'm so sorry, many hours without any break in front of the computer. Thanks for notify
|
|
|
|
|
We've all been there, there is even a phrase for it[^]
“Education is not the piling on of learning, information, data, facts, skills, or abilities - that's training or instruction - but is rather making visible what is hidden as a seed” “One of the greatest problems of our time is that many are schooled but few are educated”
Sir Thomas More (1478 – 1535)
|
|
|
|
|
Hello Experts,
I am working on an Excel application and I have input in the form of an HTML table string.I need to past this string in my excel work sheet.
Please let me know how can I do this?
Thanks,
Raesa
|
|
|
|
|
|
Hello Richard,
Thanks for the reply.
I had actually gone through the articles before, but could not find help.
I actually tried using the below code for pastiny HTML table string to excel datasheet, but it throws a pastespecial error and i'm not sure how to solve it.
-------
Excel.Application objExcelApp;
Excel.Workbook objWorkBook;
Excel.Worksheet xlWorkSheet;
object misValue = System.Reflection.Missing.Value;
objExcelApp = new Excel.Application();
objWorkBook = objExcelApp.Workbooks.Add(misValue);
xlWorkSheet = (Excel.Worksheet)objWorkBook.Worksheets.get_Item(1);
PulleyResponse respUser = PulleyOutputList.ElementAt(0).Key;
Clipboard.SetData(DataFormats.Html, respUser.htmlStressTable);
objWorkBook.ActiveSheet.Range("A1").PasteSpecial(Excel.XlPasteType.xlPasteAll,Excel.XlPasteSpecialOperation.xlPasteSpecialOperationAdd,false, false);
objWorkBook.ActiveSheet.Range("A1").Value = objWorkBook.ActiveSheet.PasteSpecial(Clipboard.GetText());
string sDesktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
if (objWorkBook != null)
objWorkBook.SaveAs("c:\\Test.xls", misValue, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlNoChange, misValue, misValue, misValue, misValue, misValue);
objExcelApp.Quit();
ReleaseObject(objWorkBook);
ReleaseObject(objExcelApp);
------
I would glad if I could get some advice on this if I am doing something wrong.
Thanks,
Raesa
|
|
|
|
|
You need to look at the information in the exception to see why it's failing.
Use the best guess
|
|
|
|
|
Hello Richard,
I am getting a COMException - "
Unable to get the PasteSpecial property of the Range class " at this line
objWorkBook.ActiveSheet.Range("A1").Value = objWorkBook.ActiveSheet.PasteSpecial(Clipboard.GetText());
I am not sure what I must do.
Thanks
Raesa
|
|
|
|
|
Hello,
As an alternative, you can take a look at IPOI[^].
Cheers,
Eduardo
|
|
|
|
|
According to the documentation[^] PasteSpecial is a method of a Range object, not a WorkSheet .
Use the best guess
|
|
|
|