|
EvanSaunders wrote: The sarcasm in your message is noted... but thanks!
Not very subtle I know, but it's amazing how many questions posted here could be, at least part-way, solved by a simple Google search. Often the top hit on the search is a CodeProject article.
|
|
|
|
|
It's not a big deal about the sarcasm, just noted it.
To be honest, I have Googled this quite a lot, and all the results come up short on the last bit of detail, which is to have a different comboBox for each row, or changing an item in the comboBox for a particular row.
Each method that I implement from what I Googled showed different ways of adding a comboBox Column, but then the comboBoxes are the same for each row. That worked for some parts of my program, but others required differences.
I appreciate your feedback (sarcasm and all), and I am glad to announce that I have finally fixed the problem, with not so much help from Google (I probably browsed more than 15 different sites, just today)
Thanks!
|
|
|
|
|
Hi, I have two .net application (exe). Prog1 and Prog2
What I would like to do is run the first program (prog1) and then from "prog1" run the second prgram "prog2"
at this point I want "prog1", to wait until "prog2" (does not exit) but gets to a certain point in its process, so I will need to send a callback to "Prog1"
I know I can use process.start to call the second program, and I can also wait until the program has exited, but what I cannot work out is how to wait until a call back is recieved and send that callback to prog1.
Can anyone help please
c# or vb.net I don'y mind.
|
|
|
|
|
There maybe a more politically correct solution but...
You could instead of using process.start, use loadassembly. Then either pass a delegate into proj2 and have it invoke it when it gets to the point you refer to or you could also use an event to trigger the action (your choice obviously).
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
Not sure if this will work but...
could you not make prog1 com visible and then expose the function in prog1 that you want prog2 to call when it gets to a specific point in its processing?
I've used this process to get jscript code sitting behind an Internet Explorer page to call a function in my vb.net app
|
|
|
|
|
Hi,
You need interprocess synchronization! There are several methods, but as I'm not an expert at this I'll just give one simple and possibly naive example using a named mutex.
Process1:
using System;
using System.Diagnostics;
using System.Threading;
static void Main() {
String mutexName = Guid.NewGuid().ToString();
Process p = Process.Start(@"Process2", mutexName);
Console.WriteLine("Waiting for Process2 to create the mutex {0}", mutexName);
Mutex m = null;
do {
try {
m = Mutex.OpenExisting(mutexName);
} catch (WaitHandleCannotBeOpenedException) {
Thread.Sleep(50);
}
} while (m == null);
Console.WriteLine("Process1 has opened the mutex, waiting for release");
if (m.WaitOne(20000)) {
Console.WriteLine("Mutex was released");
} else {
Console.WriteLine("Wait period exceeded");
}
Console.WriteLine("Press enter to exit");
Console.ReadLine();
}
Process1 starts Process2 passing the desired name of the synchronisation object.
Process1 then polls until the Mutex has been created by Process2.
Process1 can now wait for Process2 to release the Mutex.
Process2:
static void Main(String[] args) {
Console.WriteLine("Process2 created mutex {0}", args[0]);
Mutex m = new Mutex(true, args[0]);
Console.WriteLine("Process2 simulating work for 5 seconds ...");
Thread.Sleep(5000);
m.ReleaseMutex();
Console.WriteLine("Process2 released mutex ...");
Console.WriteLine("Process2 doing something else ...");
Thread.Sleep(5000);
Console.WriteLine("Press enter to exit");
Console.ReadLine();
}
There are several articles here on CodeProject. Try searching for interprocess communication or synchronisation.
Alan.
|
|
|
|
|
thank you very much , this is exactly what i need, excellent thanks
|
|
|
|
|
Hi,
I am developing a vb.net application in which i uploading some paramenters which is given below "FirstName,MiddleName,LastName,MyImage".
Uploading is done successfully but image is not showing at webpage. It is uploading FirstName, MiddleName, LastName not Myimage.
My Code is below:
myUri = New Uri("https://www.mysite.com/apis/CreateMyContact.cfm")
data = data.Append("&FirstName=" & System.Web.HttpUtility.UrlEncode(Dharm))
data = data.Append("&MiddleName=" & System.Web.HttpUtility.UrlEncode(Chand))
data = data.Append("&LastName=" & System.Web.HttpUtility.UrlEncode(Dhingra))
data = data.Append("&NickName=" & System.Web.HttpUtility.UrlEncode(Dharmu))
Dim fs As System.IO.FileStream = Nothing
Dim imgByte() As Byte = Nothing
Try
fs = System.IO.File.Open(image_path, IO.FileMode.Open, FileAccess.Read)
ReDim imgByte(fs.Length)
fs.Read(imgByte, 0, fs.Length)
fs.Close()
fs.Dispose()
fs = Nothing
Catch ex As System.Exception
End Try
If Not IsNothing(imgByte) Then
data = data.Append("&PhotoBinary=" & System.Web.HttpUtility.UrlEncode(imgByte)) 'image_path)) '
End If
'Create a byte array of the data we want to send
Dim requestBytes As Byte() = System.Text.UTF8Encoding.UTF8.GetBytes(data.ToString())
Dim oWeb As New System.Net.WebClient()
oWeb.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
Try
Dim bytRetData As Byte() = oWeb.UploadData(myUri, "POST", requestBytes)
Catch ex As WebException
End Try
This code is working successfully but image is not uploading.
Please guide me if i did wrong something in code.
Regards
Dharmchand dhingra
|
|
|
|
|
Remove all of your Try/Catch garbage since you're just eating errors and not showing them or reporting them in any way. If you're code is running into a problem, you'll never know it.
|
|
|
|
|
Hi, Thanks for reply.
In this code, no any error is coming. I am able to add records successfully on server side but at server image is not displaying. I debug this code and there is no any error occurred.
Any suggestion...
Regards
Dharmchand Dhingra
|
|
|
|
|
Hi All,
In my sql database table, date is stored as "09/15/2009" i.e. in "MM/dd/YYYY" format.
Now i want to convert this in to "dd/MM/YYYY" i.e.15/09/2009. How to do this?
I tried the following:
Date cdate = #09/15/2009# ( retrieved from database)
Dim ddto As string
ddto = cdate.ToString("dd/MM/yyyy") --> get converted to string
Dim conDate As Date
conDate = DateTime.Parse(ddto,Globalization.CultureInfo.CreateSpecificCulture("pt-US"))
Using above i am not able to convert the date back from string format to date format using Parse function. I want finally the date format as dd/MM/YYYY instead of string format. How to do this?
Thanks.
|
|
|
|
|
jeshra279 wrote: In my sql database table, date is stored as "09/15/2009" i.e. in "MM/dd/YYYY" format.
No, its simply stored as a number. The display format is based on your SQL Server settings.
You do not need to convert it to another format to work with it, only when you want to display it. Then you do a tostring with the required format - just look in the help for date format, it gives loads of examples.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
It is stored as Date format as in my sql database table column datatype is Date.
I need to convert this to dd/MM/YYYY format but with date datatype, not in string.
|
|
|
|
|
As Bob said previously a Date datatype does not have a format, it merely holds a number representing a date. Only when you need to display it on an output device does it get formatted, and this is done by converting it to a string using a standard or custom format.
|
|
|
|
|
I know it has to be converted to string, but if i convert this to a string instead of date, I am not able to get correct result using the command:
cmd = New SqlCommand("SELECT [Client ID] FROM client_details WHERE [Date of Joining] <= '" + dateofj + "'GROUP BY [Client ID]", con)
The above results in incorrect data if i use this as an string, thats why i want to convert this into Date format.
pls let me know how to convert this into date format.
|
|
|
|
|
jeshra279 wrote: pls let me know how to convert this into date format.
Sorry, I don't understand what you are saying, I thought this was a Date type not a string.
|
|
|
|
|
jeshra279 wrote: + dateofj +
Is where your problem lies I suspect. I expect it is in a format something like 10/10/2009 which can either be DD/MM or MM/DD. Put it into a format like '10 Oct 2009' so that SQL Server can be certain of the format.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Or use a SqlParameter in which case it can be passed directly as a date without having to worry about format at all.
|
|
|
|
|
A double advice:
- store dates and datetimes as such in the database, never store them as strings;
- pass dates and datetimes as SQL paramters, avoid passing them as strings.
If you do both, you'll never have any date formatting problems, as there no longer is any formatting going on. Formatting should be relevant only in the user interface.
|
|
|
|
|
As per Your 2nd point, am i passing the dates and datetimes as SQL paramters in my following select command:
cmd = New SqlCommand("SELECT [Client ID] FROM client_details WHERE [Date of Joining] = '" + dateofj + "'GROUP BY [Client ID]", con)
|
|
|
|
|
No you are not. You are passing a string, and C# is implicitly calling dateofj.ToString() to perform a string concatenation afterwards; that is where the regional settings are sneaking in your code.
You need this[^] to be safe.
|
|
|
|
|
Instead of
cmd = New SqlCommand("SELECT [Client ID] FROM client_details WHERE [Date of Joining] = '" + dateofj + "'GROUP BY [Client ID]", con)
use:
cmd = New SqlCommand("SELECT [Client ID] FROM client_details WHERE [Date of Joining] = @DateOfJ GROUP BY [Client ID]", con)
cmd.Parameters.AddWithValue(@DateOfJ, YourDateValueHere)
|
|
|
|
|
Hey guys I am currently making a program that will allow a user to open/create a file and then after adding data to the file
he/she can search the file by Record number. But i am trying to come up with a If statement that will test if the Recordnumber
the user enters is NOT FOUND then display an error message, I have written this so far, but it doesn't like how I am
trying to convert a string to a double. THANKS for the HELP
Module modulePersonRec
Structure personRecord
<VBFixedString(7)> Public RecordNum As String
<VBFixedString(9)> Public SS As String
<VBFixedString(40)> Public name As String
<VBFixedString(10)> Public Tele As String
<VBFixedString(2)> Public lineBreak As String
End Structure
Public datafile As String
Public person As personRecord
Public position As Long
Public lastrec As Long
Public RecLength As Long
Public LastRecord As Integer
Public filelength As Long
Public indexSS(100) As String
Public indexKey(100) As Long
End Module
Private Sub btnGet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGet.Click
'*****************************************************88
'THIS SUBROUTINE WILL ALLOW THE USER TO FIND A RECORD
'BASED ON THE RECORD NUMBER THE USER ENTERS INTO
'A REQUIRED FIELD. IF THE RECORD IS FOUND THEN
'THE CORRESPONDING DATA WILL BE DISPLAYED
'****************************************************
FileGet(1, person, Val(txtRecNum.Text))
If person.RecordNum <> Val(txtRecNum.Text) Then
MessageBox.Show("Record Does not exist", "RandomFile", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
FileGet(1, person, Val(txtRecNum.Text))
txtSSN.Text = person.SS
txtName.Text = person.name
txtTele.Text = person.Tele
End If
End Sub
I AM ALSO HAVING A PROBLEM WHEN TRYING TO ALLOW UPDATES TO A SPECIFIC RECORD, WHEN I LOOK UP A RECORD NUMBER AND THEN
TRY SAVING THE CHANGES IT DOES NOT CHANGE THAT SPECIFIC RECORD WHAT IT IS DOING RIGHT NOW IS IT WILL ADD IT TO THE FILE
BUT IT THEN APPENDS OR ERASES THE NEXT FILE SO IF I HAD 3 RECORDS AND I SAY I WANNA CHANGE THE 1ST REC, IT WILL APPEND OR ERASE ITSELF TO THE 2ND POSITION IN THE FILE AND THE PREVIOUS 2ND RECORD WILL NOW BE DELETED. ???? IT IS HOWEVER SAVING JUST
NOT TO THE RIGHT INDEX
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
'**********************************************
'THIS SUBROUTINE WILL UPDATE ANY CHANGES
'THE USER ENTERS TO A SPECIFIC RECORD
'HE/SHE FINDS AFTER SEARCHING BY REC NUM
'**********************************************
'Update the information of an person.
' person.RecordNum = Val(txtRecNum.Text)
person.name = txtName.Text
person.SS = txtSSN.Text
person.Tele = txtTele.Text
FilePut(1, person, )
End Sub
modified on Wednesday, December 9, 2009 3:18 AM
|
|
|
|
|
WHy does this assignmnet reek of homework??
|
|
|
|
|
Sorry its just a program needed for class and I have it almost working but cant find a way around my problem I am running into
|
|
|
|