|
my code is like this in windows services class
<br />
protected override void OnStart(string[] args)<br />
{<br />
insertValues(3, "Naresh Kumar", "3658213641", "Begumpet, Hyderabad");<br />
}<br />
<br />
public void insertValues(int custId, string custName, string custPhone, string custAdd)<br />
{<br />
string insertCommand = "Insert into CUSTOMER values ( " + custId + ",'" + custName + "','" + custPhone + "','" + custAdd + "')";<br />
con.Open();<br />
cmd = new SqlCommand(insertCommand, con);<br />
cmd.ExecuteNonQuery();<br />
con.Close();<br />
}<br />
when am trying run this service from computer Mangement
is it displaying below alert
"The service on local machine started and stopped. some services stopped automatically if they have no work to do for example the performance logs and alerts service."
please help me out
|
|
|
|
|
The reason it stopped automatically is because there is no further work for the service to do once the line insertValue(...) has run.
In general, windows services' OnStart method starts a thread/timer which continues to process until interupted by a Pause or Stop command.
Whatever a "PL" is, he is an idiot, or you have misunderstood his request.
|
|
|
|
|
Hi,
I have a template in location " c:\excel_temp\template1.xls". This template is a user defined template.
I have to use this template in a browsed location. ( if user selects "d:\temp\" folder, then I have to import the template in " c:\excel_temp" to "d:\temp" folder).
I am trying this with C#. i have done somepart of it
string tempPath = @"D:\Documents and Settings\eob\Desktop\Testing";
//System.IO.Directory.CreateDirectory(@tempPath + launchName);
//check path exists
if (!System.IO.Directory.Exists(@tempPath + launchName))
{
System.IO.Directory.CreateDirectory(@tempPath + launchName);
}
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(@tempPath + launchName);
int directoryCount = dir.GetFiles().Length;
if (directoryCount != 0)
{
FileInfo[] fileNames = dir.GetFiles(@tempPath + launchName);
}
Excel.Application excelFile = new Excel.ApplicationClass();
Now with the excelFile created above, I have to access the template and create an excel file same as the template in the above folder.
I am stuck at this point, pls guide me
Thanks
Ramm
|
|
|
|
|
Krishna Aditya wrote: I have a template in location " c:\excel_temp\template1.xls". This template is a user defined template.
I have to use this template in a browsed location. ( if user selects "d:\temp\" folder, then I have to import the template in " c:\excel_temp" to "d:\temp" folder).
for this you can use:
string source = "c:\excel_temp\template1.xls";
string Destination = "d:\temp\Temp.xls";
if (File.Exists(Destination))
{
File.Copy(source, Destination, true);
}
//refer : Word automation (Part 1)[^]
modified on Monday, June 29, 2009 7:37 AM
|
|
|
|
|
Hello Experts
I want to make my columnheader Readonly of my datagrid...
|
|
|
|
|
what do you want with columnheader readonly ?
do you mean "not clickable and not sortable" ?
|
|
|
|
|
Yes i want that it should not be clicked,because when i click header, my control goes in cell click event and executes the code in it and error arises.
|
|
|
|
|
private void dataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
{
if(e.RowIndex < 0)
return;
}
|
|
|
|
|
|
rhtbhegade wrote: columnheader Readonly of my datagrid
what do you mean by readonly... Plz make your question clear so that our experts could give correct suggestions...
|
|
|
|
|
I have also same problem,i want to avoid click on header.then whats procedure?
|
|
|
|
|
if i am correct you dont want to sort columns...
There is options for that..
You have to bind the values as BoundField and in the properties of the Grid select Columns.
In that collections you can find the Bound field which you have specified.
In that bound Field there is a option "SortMode" make that to "NotSortable"
|
|
|
|
|
One night I came up with a random idea to make an ultrasonic underwater exploration robot. This robot will use ultrasonic transducers to communicate with a laptop on the surface of a body of water. I found some test transducers which are water proof and I got a small aquarium tank to test the devices in. Now, I never worked with communications nor have done much analog to digital interface work...long story short I'm a communications newbie who needs a little push in the right direction. What I am asking for is some information or link to a place where I can learn more about how to receive digital output data from my sensor circuit using C#. The output is TTL logic (5v+) and I am not sure how to go about obtaining the data that is being outputted. So I just connect the output to the data line of a USB and open up hyper terminal? Will i receive anything? I apologize for what might be stupid questions. Any help would be greatly appreciated.
|
|
|
|
|
AFAIK, the serial port is your best bet, interfacing to an inpout.dll ( there's one on CP somewhere )
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
It may be worth having a look at how external microcontrollers (microchip, atmel etc...) interface with computers to get some pointers. There are lots of examples around. You may find the easiest way could be to connect your hardware to one of those and use that to communicate with the computer via USART/SPI or whatever.
It can be done with a USB connection but that is going to be complicated. As Christian said, a serial port connection will probably be the easiest solution.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Direct connection between the actual transducer and teh serial / USB port won't work, unless (very unlikely) it transducer has an AtoD converter and interface built in. What yours provides is a TTL level: 0V or +5V (nominal, above ~3V is allowed) TTL Levels if you need to know or are interested.[^]
What you will need to do is to connect the transducer to either an interface board or some microcontroller (try PIC) that can interface directly to serial / USB.
You can then use whatever communications protocol you need (and can implement!)
Good luch, and have fun!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Thanks again you have all been great help...Once I'm done I will post my work on the site, if its good enough. I'm sure someone somewhere will be interested in underwater ultrasonic communications. : )
|
|
|
|
|
in database the column is like this
EngyVal
10.05
111.9
11.89
after executing my query i want the above values as below
EngyVal
0010.05
0111.90
0011.89
how can i format the column in the select statement
|
|
|
|
|
Well, this would be a SQL question, except that you can't. The data in your database is not formatted in the DB, or in your dataset. It's formatted when you display it.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
You can't.
What you need to do is format the output - wherever that is going.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
You could write function, but formatting is best handled at the client.
|
|
|
|
|
Hi,
Kindly let me know that, How may I send message to particular client. if four client are already connected. I want to send message to fourth-one.
Following Server-side script is working very good but it sends to every one.
please tell me where will I have to change following script to send message to particular client.
Thank you
Script is here:
using System;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
namespace DefaultNamespace
{
public class SocketServer : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.RichTextBox richTextBoxReceivedMsg;
private System.Windows.Forms.TextBox textBoxPort;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox textBoxMsg;
private System.Windows.Forms.Button buttonStopListen;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.RichTextBox richTextBoxSendMsg;
private System.Windows.Forms.TextBox textBoxIP;
private System.Windows.Forms.Button buttonStartListen;
private System.Windows.Forms.Button buttonSendMsg;
private System.Windows.Forms.Button buttonClose;
const int MAX_CLIENTS = 10;
public AsyncCallback pfnWorkerCallBack ;
private Socket m_mainSocket;
private Socket [] m_workerSocket = new Socket[10];
private int m_clientCount = 0;
public SocketServer()
{
InitializeComponent();
textBoxIP.Text = GetIP();
}
[STAThread]
public static void Main(string[] args)
{
Application.Run(new SocketServer());
}
#region Windows Forms Designer generated code
private void InitializeComponent() {
this.buttonClose = new System.Windows.Forms.Button();
this.buttonSendMsg = new System.Windows.Forms.Button();
this.buttonStartListen = new System.Windows.Forms.Button();
this.textBoxIP = new System.Windows.Forms.TextBox();
this.richTextBoxSendMsg = new System.Windows.Forms.RichTextBox();
this.label1 = new System.Windows.Forms.Label();
this.buttonStopListen = new System.Windows.Forms.Button();
this.textBoxMsg = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.textBoxPort = new System.Windows.Forms.TextBox();
this.richTextBoxReceivedMsg = new System.Windows.Forms.RichTextBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.SuspendLayout();
this.buttonClose.Location = new System.Drawing.Point(321, 232);
this.buttonClose.Name = "buttonClose";
this.buttonClose.Size = new System.Drawing.Size(88, 24);
this.buttonClose.TabIndex = 11;
this.buttonClose.Text = "Close";
this.buttonClose.Click += new System.EventHandler(this.ButtonCloseClick);
this.buttonSendMsg.Location = new System.Drawing.Point(16, 192);
this.buttonSendMsg.Name = "buttonSendMsg";
this.buttonSendMsg.Size = new System.Drawing.Size(192, 24);
this.buttonSendMsg.TabIndex = 7;
this.buttonSendMsg.Text = "Send Message";
this.buttonSendMsg.Click += new System.EventHandler(this.ButtonSendMsgClick);
this.buttonStartListen.BackColor = System.Drawing.Color.Blue;
this.buttonStartListen.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.buttonStartListen.ForeColor = System.Drawing.Color.Yellow;
this.buttonStartListen.Location = new System.Drawing.Point(227, 16);
this.buttonStartListen.Name = "buttonStartListen";
this.buttonStartListen.Size = new System.Drawing.Size(88, 40);
this.buttonStartListen.TabIndex = 4;
this.buttonStartListen.Text = "Start Listening";
this.buttonStartListen.Click += new System.EventHandler(this.ButtonStartListenClick);
this.textBoxIP.Location = new System.Drawing.Point(88, 16);
this.textBoxIP.Name = "textBoxIP";
this.textBoxIP.ReadOnly = true;
this.textBoxIP.Size = new System.Drawing.Size(120, 20);
this.textBoxIP.TabIndex = 12;
this.textBoxIP.Text = "";
this.richTextBoxSendMsg.Location = new System.Drawing.Point(16, 87);
this.richTextBoxSendMsg.Name = "richTextBoxSendMsg";
this.richTextBoxSendMsg.Size = new System.Drawing.Size(192, 104);
this.richTextBoxSendMsg.TabIndex = 6;
this.richTextBoxSendMsg.Text = "";
this.label1.Location = new System.Drawing.Point(16, 40);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(48, 16);
this.label1.TabIndex = 1;
this.label1.Text = "Port";
this.buttonStopListen.BackColor = System.Drawing.Color.Red;
this.buttonStopListen.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.buttonStopListen.ForeColor = System.Drawing.Color.Yellow;
this.buttonStopListen.Location = new System.Drawing.Point(321, 16);
this.buttonStopListen.Name = "buttonStopListen";
this.buttonStopListen.Size = new System.Drawing.Size(88, 40);
this.buttonStopListen.TabIndex = 5;
this.buttonStopListen.Text = "Stop Listening";
this.buttonStopListen.Click += new System.EventHandler(this.ButtonStopListenClick);
this.textBoxMsg.BackColor = System.Drawing.SystemColors.Control;
this.textBoxMsg.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.textBoxMsg.ForeColor = System.Drawing.SystemColors.HotTrack;
this.textBoxMsg.Location = new System.Drawing.Point(120, 240);
this.textBoxMsg.Name = "textBoxMsg";
this.textBoxMsg.ReadOnly = true;
this.textBoxMsg.Size = new System.Drawing.Size(192, 13);
this.textBoxMsg.TabIndex = 14;
this.textBoxMsg.Text = "None";
this.label4.Location = new System.Drawing.Point(16, 71);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(192, 16);
this.label4.TabIndex = 8;
this.label4.Text = "Broadcast Message To Clients";
this.label5.Location = new System.Drawing.Point(217, 71);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(192, 16);
this.label5.TabIndex = 10;
this.label5.Text = "Message Received From Clients";
this.textBoxPort.Location = new System.Drawing.Point(88, 40);
this.textBoxPort.Name = "textBoxPort";
this.textBoxPort.Size = new System.Drawing.Size(40, 20);
this.textBoxPort.TabIndex = 0;
this.textBoxPort.Text = "8000";
this.richTextBoxReceivedMsg.BackColor = System.Drawing.SystemColors.InactiveCaptionText;
this.richTextBoxReceivedMsg.Location = new System.Drawing.Point(217, 87);
this.richTextBoxReceivedMsg.Name = "richTextBoxReceivedMsg";
this.richTextBoxReceivedMsg.ReadOnly = true;
this.richTextBoxReceivedMsg.Size = new System.Drawing.Size(192, 129);
this.richTextBoxReceivedMsg.TabIndex = 9;
this.richTextBoxReceivedMsg.Text = "";
this.label2.Location = new System.Drawing.Point(16, 16);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 16);
this.label2.TabIndex = 2;
this.label2.Text = "Server IP";
this.label3.Location = new System.Drawing.Point(0, 240);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(112, 16);
this.label3.TabIndex = 13;
this.label3.Text = "Status Message:";
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(424, 260);
this.Controls.Add(this.textBoxMsg);
this.Controls.Add(this.label3);
this.Controls.Add(this.textBoxIP);
this.Controls.Add(this.buttonClose);
this.Controls.Add(this.label5);
this.Controls.Add(this.richTextBoxReceivedMsg);
this.Controls.Add(this.label4);
this.Controls.Add(this.buttonSendMsg);
this.Controls.Add(this.richTextBoxSendMsg);
this.Controls.Add(this.buttonStopListen);
this.Controls.Add(this.buttonStartListen);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBoxPort);
this.Name = "SocketServer";
this.Text = "SocketServer";
this.ResumeLayout(false);
}
#endregion
void ButtonStartListenClick(object sender, System.EventArgs e)
{
try
{
if(textBoxPort.Text == ""){
MessageBox.Show("Please enter a Port Number");
return;
}
string portStr = textBoxPort.Text;
int port = System.Convert.ToInt32(portStr);
m_mainSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
IPEndPoint ipLocal = new IPEndPoint (IPAddress.Any, port);
m_mainSocket.Bind( ipLocal );
m_mainSocket.Listen (4);
m_mainSocket.BeginAccept(new AsyncCallback (OnClientConnect), null);
UpdateControls(true);
}
catch(SocketException se)
{
MessageBox.Show ( se.Message );
}
}
private void UpdateControls( bool listening )
{
buttonStartListen.Enabled = !listening;
buttonStopListen.Enabled = listening;
}
public void OnClientConnect(IAsyncResult asyn)
{
try
{
m_workerSocket[m_clientCount] = m_mainSocket.EndAccept (asyn);
WaitForData(m_workerSocket[m_clientCount]);
++m_clientCount;
String str = String.Format("Client # {0} connected", m_clientCount);
textBoxMsg.Text = str;
m_mainSocket.BeginAccept(new AsyncCallback ( OnClientConnect ),null);
}
catch(ObjectDisposedException)
{
System.Diagnostics.Debugger.Log(0,"1","\n OnClientConnection: Socket has been closed\n");
}
catch(SocketException se)
{
MessageBox.Show ( se.Message );
}
}
public class SocketPacket
{
public System.Net.Sockets.Socket m_currentSocket;
public byte[] dataBuffer = new byte[1];
}
public void WaitForData(System.Net.Sockets.Socket soc)
{
try
{
if ( pfnWorkerCallBack == null ){
pfnWorkerCallBack = new AsyncCallback (OnDataReceived);
}
SocketPacket theSocPkt = new SocketPacket ();
theSocPkt.m_currentSocket = soc;
soc .BeginReceive (theSocPkt.dataBuffer, 0,
theSocPkt.dataBuffer.Length,
SocketFlags.None,
pfnWorkerCallBack,
theSocPkt);
}
catch(SocketException se)
{
MessageBox.Show (se.Message );
}
}
public void OnDataReceived(IAsyncResult asyn)
{
try
{
SocketPacket socketData = (SocketPacket)asyn.AsyncState ;
int iRx = 0 ;
iRx = socketData.m_currentSocket.EndReceive (asyn);
char[] chars = new char[iRx + 1];
System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
int charLen = d.GetChars(socketData.dataBuffer,
0, iRx, chars, 0);
System.String szData = new System.String(chars);
richTextBoxReceivedMsg.AppendText(szData);
WaitForData( socketData.m_currentSocket );
}
catch (ObjectDisposedException )
{
System.Diagnostics.Debugger.Log(0,"1","\nOnDataReceived: Socket has been closed\n");
}
catch(SocketException se)
{
MessageBox.Show (se.Message );
}
}
void ButtonSendMsgClick(object sender, System.EventArgs e)
{
try
{
Object objData = richTextBoxSendMsg.Text;
byte[] byData = System.Text.Encoding.ASCII.GetBytes(objData.ToString ());
for(int i = 0; i < m_clientCount; i++){
if(m_workerSocket[i] != null){
if(m_workerSocket[i].Connected){
m_workerSocket[i].Send (byData);
}
}
}
}
catch(SocketException se)
{
MessageBox.Show (se.Message );
}
}
void ButtonStopListenClick(object sender, System.EventArgs e)
{
CloseSockets();
UpdateControls(false);
}
String GetIP()
{
String strHostName = Dns.GetHostName();
IPHostEntry iphostentry = Dns.GetHostByName(strHostName);
String IPStr = "";
foreach(IPAddress ipaddress in iphostentry.AddressList){
IPStr = ipaddress.ToString();
return IPStr;
}
return IPStr;
}
void ButtonCloseClick(object sender, System.EventArgs e)
{
CloseSockets();
Close();
}
void CloseSockets()
{
if(m_mainSocket != null){
m_mainSocket.Close();
}
for(int i = 0; i < m_clientCount; i++){
if(m_workerSocket[i] != null){
m_workerSocket[i].Close();
m_workerSocket[i] = null;
}
}
}
}
}
|
|
|
|
|
M Riaz Bashir wrote: for(int i = 0; i < m_clientCount; i++){
if(m_workerSocket[i] != null){
if(m_workerSocket[i].Connected){
m_workerSocket[i].Send (byData);
}
}
}
I have two reasons to believe that you really have not the slightest idea what you're doing.
1 - you posted a ton of useless boilerplate code
2 - if you can't work out from this how to send to only one user, then you should take a class, read a book, do SOMETHING to create a basic understanding of programming before you play with other people's code. I assume you're playing with something you found online to teach yourself, I can't see how this could be work or school. So, take a step back, buy a book, and learn how to read some basic code before you start trying to mash up other people's.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Christian Graus wrote: I have two reasons to believe that you really have not the slightest idea what you're doing
I agree
Moim Hossain
R&D Project Manager
BlueCielo ECM Solutions BV
|
|
|
|
|
i need to show a preview of my webcam in a picture box when i connected to the webcam. im using WIA.
how can i show preview of my webcam in a picturebox.
here is my code to connect to webcam...
private void btnDecode_Click_1(object sender, EventArgs e)
{
try
{
Cursor.Current = Cursors.WaitCursor;
DeviceManager manager = new DeviceManagerClass();
Device d = null;
foreach (DeviceInfo info in manager.DeviceInfos)
{
d = info.Connect();
}
Item item = d.ExecuteCommand(CommandID.wiaCommandTakePicture);
foreach (string format in item.Formats)
{
i++;
WIA.ImageFile imagefile = item.Transfer(format) as WIA.ImageFile;
imagefile.SaveFile("d:\\" + i + ".jpg");
Bitmap image = new Bitmap("d:\\" + i + ".jpg");
Bitmap bm = new Bitmap(image, 200, 150);
Gray(bm);
|
|
|
|
|