|
Did you use search? There are several articles at codeproject showing how to achieve it.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Try searching for "hooks"
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
I have 2 connections strings in the settings file that are used by various datasetgridviews and other functions. The problem comes in that the databases are in the \CurrentUser\My Document\MyProgramsDataFolder. Other data is also being stored here for processing.
I know this may not be considered a "Best programming practice", but it suits the nature of the program.
Is there anyway of setting the connection sting in the settings file so that instead of
Data Source=.\SQLEXPRESS;AttachDbFilename="|DataDirectory|Database1.mdf";Integrated Security=True;Connect Timeout=30;User Instance=True
it looks something like
Data Source=.\SQLEXPRESS;AttachDbFilename="|MyDocuments|Database1.mdf";Integrated Security=True;Connect Timeout=30;User Instance=True
|
|
|
|
|
The |DataDirectory| value is a substitution string that indicates the path to the database so you don't have to hard-code the full path. There is no corresponding |MyDocuments| substition string.
What you should do is call the AppDomain.SetData[^] method. If you don't, the following rules are applied:- For applications that are put in a folder on the user's computer, the database folder uses the application folder.
- For applications that are running under ClickOnce, the database folder uses the specific data folder that is created.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines][ Articles][ Blog]
|
|
|
|
|
I have a file that opens automatically with an excelApp.Workbooks.Open statement, i.e., I'm not using MessageBox.Show. If the file is in use, I get the message, "'filename' is being modified. Open as read-only", with OK and Cancel as options. I need to trap the "Cancel" option so I can take various actions if the user chooses this. But since I didn't use the MessageBox, class, how do I do this?
|
|
|
|
|
I guess the obvious thing is, can you check afterwards if it opened or not ? If it didn't open, you can assume they pressed cancel ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian: Sorry, I guess I didn't explain it very well. The Excel file being opened is in background and isn't launched by the user. However, if there's an Excel object left open from an exception being thrown during testing, then during the next program launch, I get prompted by Excel that the file is open and do I want to open a Read Only version. I'd like to be able to Cancel at that point but, if I do, I get a COM exception. So I'd like to trap the Cancel and redirect the code so I don't get an exception. But I don't know how to do that without using the DialogResult class.
|
|
|
|
|
I am working on a community site i want to store the array of frinds in the profile of the user. I have looked for it on google but could'nt find. Is it possible or not. Thks
(or can an object be stored in profile? )
|
|
|
|
|
Sounds like an ASp.NET question ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I have come to CP after searching Google so ur answer is not helpful in any way .......
|
|
|
|
|
Muhammad Zeeshan wrote: I have come to CP after searching Google
That's great, that you looked somewhere first.
Muhammad Zeeshan wrote: ur answer is not helpful in any way
Actually, it's very helpful. Pointing out to you that we have an ASP.NET forum ( which you still haven't found, I just answered this in the web dev forum ), means that
a - you don't clutter our forums with off topic questions, and
b - you ask in a place where people who can help you, will look.
Which just means you get an answer faster. Sorry if you don't think that will help you at all.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
oh yes thks sorry for being rude. new to CP now definitly will find right forums to put questions thanks for ur kind help.
|
|
|
|
|
Glad to help
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi
I recieve this exception:
"Only one usage of each socket address (protocol/network address/port) is normally permitted"
I should get several files from an ftp server. I implemented it by sockets so: create the datasocket, recieve the file and then close data socket. But the next time I do this for another file(create data socket with Endpoint (the same local address/another port)), i recieve this exception message when Binding the socket. Can anyone tell me why? And the way to solve that?
(the code, if necessary)
public void download(string remFileName, string locFileName)
{
if (!logined)
{
login();
}
setBinaryMode(true);
Console.WriteLine("Downloading file " + remFileName + " from " + remoteHost + "/" + remotePath);
if (locFileName.Equals(""))
{
locFileName = remFileName;
}
if (!File.Exists(locFileName))
{
Stream st = File.Create(locFileName);
st.Close();
}
FileStream output = new FileStream(locFileName, FileMode.Open);
createDataSocket(true);
if (dataSocket != null)
{
throw new SocketException();
}
sendCommand("RETR " + remFileName);
if (!(retValue == 150 || retValue == 125))
{
throw new IOException(reply.Substring(4));
}
dataSocket = listeningSocket.Accept();
listeningSocket.Close();
listeningSocket = null;
if (dataSocket == null)
{
throw new Exception("Winsock error: " +
Convert.ToString(System.Runtime.InteropServices.Marshal.GetLastWin32Error()));
}
while (true)
{
bytes = dataSocket.Receive(buffer, buffer.Length, 0);
output.Write(buffer, 0, bytes);
if (bytes <= 0)
{
break;
}
}
output.Close();
if (dataSocket.Connected)
{
dataSocket.Close();
dataSocket = null;
}
Console.WriteLine("");
readReply();
if (!(retValue == 226 || retValue == 250))
{
throw new IOException(reply.Substring(4));
}
}
public void createDataSocket(bool flag)
{
try
{
listeningSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
}
catch (Exception e)
{
ftpLog(e.Message);
throw new IOException(e.Message);
}
string localAddress = clientSocket.LocalEndPoint.ToString();
int ix = localAddress.IndexOf(':');
if (ix < 0)
throw new Exception("local IP ERROR");
string localIP = localAddress.Substring(0, ix);
IPEndPoint localEP = new IPEndPoint(IPAddress.Parse(localIP), localDataPort);
try
{
<big>listeningSocket.Bind(localEP);</big>
listeningSocket.Listen(1);
}
catch (SocketException se)
{
ftpLog(se.Message);
throw new IOException(se.Message);
}
localIP = localIP.Replace('.', ',');
string portCMD = string.Format("PORT {0},{1},{2}", localIP, localDataPort / 256, localDataPort % 256);
localDataPort++;
sendCommand(portCMD);
if(retValue!=200)
throw new IOException(reply.Substring(4));
}
|
|
|
|
|
Hi Guys. I have been busy with an Application that writes data to Excel. Now, I have successfully written the application and now I need to make some changes/enhancements. Problem is that I am unsure on how to do the following: Below a snippet of the data in Excel.
Discl Level Level 1 Level 2
1 378600
2 350000
2 28600
1 50000
2 50000
I have a disclosure Level which is the 1's and 2's on the left.
I have to somehow calculate all the Level2 totals and ensure that they balance to the Level1 balance. If there is an imblance then I need to write this into an adjacent cell to level2 on the same line as the level1. I'm not sure how to do that. I have now been searching a number of websites for a few days now and can't find anything that explains how to do this.
The other problem is that I don't know where the level 1 and level2 starts so I need to somehow be able to determine this as well.
If anybody can help with this I would greatly appreciate this or if you have a website that explains this please please let me know.
Cheers
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Since you've posted so many problems regarding excel I guess you should read this article
http://support.microsoft.com/kb/302084[^]
It has everything you need to know!!
- Stop thinking in terms of limitations and start thinking in terms of possibilities -
|
|
|
|
|
Hello,
I'm trying to navigate from the middle of the xml page back to the top(to the parent node).
So I can perform another search looking for matches to my random number,
while (xmlReader.Read())
{
xmlReader.MoveToElement();
TempNo = xmlReader.Value;
if (tempNo == Convert.ToString(userID))
{
UserID = RadNo.Next(10, 99);
}
}
The above is my code, hope this help.
Sorry if this is a simple question, I'm totally new to xml and c#
just learning it really...
-JC
|
|
|
|
|
XMLReader is forward only. Use XMLDocument class instead and use XPath to do your search.
|
|
|
|
|
hello i have been looking for this code for a long time
its about how to execute a program like excel or word or any .exe file
from c#
for example i want to make a button that runs winword when its pressed
and thx
|
|
|
|
|
Process.Start, but you need the path to Word, OR you can pass in the path to a word doc, and if Word is present, it will open. If not, it will throw an exception.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
here is a simple application I wrote :
there is a combobox on my form which lets user to select a program.
in this case i just added 3 programs to it : (mediaplayer, freecell, MinesWeeper)
also you can add the command line arguments to your process.
by clicking the run button the fallowing code will run.
private void runbtn_Click(object sender, System.EventArgs e)
{
Process myProcess = new Process();
int selectedIndex = comboBox1.SelectedIndex;
switch (selectedIndex)
{
case 0:
myProcess.StartInfo.FileName = "C:/Program Files/Windows Media Player/wmplayer.exe";
break;
case 1:
myProcess.StartInfo.FileName = "c:/windows/system32/winmine.exe";
break;
case 2:
myProcess.StartInfo.FileName = "c:/windows/system32/freecell.exe";
break;
default:
myProcess.StartInfo.FileName = "C:/Program Files/Windows Media Player/wmplayer.exe";
break;
}
myProcess.Start();
}
sometimes 0 can be 1
modified on Sunday, June 15, 2008 10:26 AM
|
|
|
|
|
Problem Description:
i need to develop an C# app with offical toolkit of Basler linear CCD ,including two dll files.
however, when i call the function "pxd_renderDIB(...)" in the dlls,there is red shifting about the Image in picturebox,meanwhile, the saved Image in disk is normal.
by the way ,the source of Image is RAW image delivered from CCD to the buffer alloced in memory.
how to correct red shift in picturebox?Thanks.
|
|
|
|
|
Sounds like the API is broken, the way you're using it is broken, or the image is broken. I don't think we can hope to help with any of those things, unless someone here has used that SDK. Your best bet is to ask on a forum of people who have the SDK you're using, so they know how to help you.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I use WritePrinter - work, but ReadPrinter return empty
[DllImport("winspool.drv", CharSet = CharSet.Ansi, ExactSpelling = true,CallingConvention = CallingConvention.StdCall)]
public static extern long ReadPrinter(IntPtr hPrinter, StringBuilder data, int buf, out int pcRead);
public static int ReadFromPrinter(string szPrinterName, string szString)
{
Int32 dwError = 0, dwWritten = 0;
IntPtr hPrinter = new IntPtr(0);
StringBuilder sb = new StringBuilder();
DOCINFOA di = new DOCINFOA();
bool bSuccess = false;
di.pDocName = "My C#.NET RAW Document";
di.pDataType = "RAW";
if (OpenPrinter(szPrinterName.Normalize(), out hPrinter, IntPtr.Zero))
{
if (StartDocPrinter(hPrinter, 1, di))
{
if (StartPagePrinter(hPrinter))
{
IntPtr pBytes;
Int32 dwCount;
System.Text.Encoding ascii = System.Text.Encoding.GetEncoding(866);
byte[] myStringInASCII = ascii.GetBytes(szString);
szString = ascii.GetString(myStringInASCII);
dwCount = szString.Length;
pBytes = Marshal.StringToCoTaskMemAnsi(szString);
bSuccess = WritePrinter(hPrinter, pBytes, dwCount, out dwWritten);
Marshal.FreeCoTaskMem(pBytes);
EndPagePrinter(hPrinter);
}
EndDocPrinter(hPrinter);
}
long out1 = ReadPrinter(hPrinter, sb, 6, out dwWritten);
ClosePrinter(hPrinter);
}
if (bSuccess == false)
{
dwError = Marshal.GetLastWin32Error();
}
return 1;
}
Where error?
thanks
|
|
|
|
|
Hi
I have developed an SSIS package in Business Intelligence Development studio.
It Works in BI and returns result.
When I attempt to execute the package programmatically from a .net Windows
Form application the follow DtsError is returned:
"The product level is insufficient for component \"Fuzzy Lookup\" (497).\r\n"
Can anyone Help me?
Thanks and regards
Sri
|
|
|
|