|
hey there, here's an app i did something similar with...
its a console app that calls "sqlCmd" to run my data base scrips, the output of each of the sqlCmd programs is dispalyed on the calling program.
Hope this helps
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading;
using System.IO;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Smo.Wmi;
using Microsoft.SqlServer.Management.Common;
namespace CreateDB
{
public class Program
{
public static string database;
public static string userName;
public static string password;
static void Main(string[] args)
{
getVariables();
FileStream fs = new FileStream(@"C:\scripts.txt", FileMode.Open, FileAccess.Read);
StreamReader sr = new StreamReader(fs);
killDatabase();
string line = sr.ReadLine();
while (line != null)
{
ProcessStartInfo StartInfo = new ProcessStartInfo("sqlcmd", "-S " + database + " -d master" + " -U " + userName + " -P " + password + " -i " + line);
Process myProcess = new Process();
StartInfo.UseShellExecute = false;
StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo = StartInfo;
myProcess.Start();
Console.Write("Started Process --> ");
myProcess.WaitForExit();
StreamReader outputReader = myProcess.StandardOutput;
Console.WriteLine("Finnished Process ---> output:" + "\r\n");
Console.WriteLine(outputReader.ReadToEnd());
Console.WriteLine();
Console.WriteLine("|------------------------------------------------------------------------------|");
Console.WriteLine();
line = sr.ReadLine();
}
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("DDDD OOOO N N EEEEEE ");
Console.WriteLine("D D O O NN N E ");
Console.WriteLine("D D O O N N N EEE ");
Console.WriteLine("D D O O N N N EEE ");
Console.WriteLine("D D O O N NN E ");
Console.WriteLine("DDDD OOOO N N EEEEEE ");
Console.ResetColor();
Console.Read();
}
private static void getVariables()
{
Console.Write("Please Enter DataBase Name: ---> ");
database = Console.ReadLine();
Console.Write("User Name ---------------------> ");
userName = Console.ReadLine();
Console.Write("Password ----------------------> ");
password = Console.ReadLine();
Console.Clear();
}
private static void killDatabase()
{
try
{
Server srv = new Server(database);
srv.KillDatabase("uniclox_db");
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex.Message);
Console.ResetColor();
}
}
}
}
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
Hello,
VS 2008
Our client wants to have a phone dialer application. So they want to have different buttons with different shapes and colours. To make it look more like a telephone dialer. They don't want to have the normal button look that are dragged on to the form.
Is there any free third party controls that have the look and feel of different buttons.
Is it possible to create these buttons yourself? Any good links to be able to do this?
Many thanks,
Steve
|
|
|
|
|
You may create a custom button class that is inherited from the button class. Then define your own paint method and draw button the way you want. You should look into GDI stuff for colouring and speicall effects. There are may ariticles on CP.
|
|
|
|
|
In my windows form I am creating 1000 objects when a button is clicked and am not disposing those obects, just to check how much memory this act is taking through the Windows Task Manager.
What I want to know that, is there any way I could figure out which class instianting or taking more memory. I tried attaching my application with the windows CLR Profiler but it's hell like complicated and it shows me so many internal classes that I freak out and to be honest don't know which area to look into. Any best suggestion would help me. Thanks
|
|
|
|
|
Actually, Windows CLR Profiler is a really good free tool for this task, if not the best free tool.
What you basically do is the following:
- Start your app from CLR profiler
- Close your app
- In the summary window go to "allocation graph" (as an example)
- In the new window you can search for a specific method using the menu "Edit" -> "Find Routine". You could enter your button click handler here
- The graph will jump to the routine you searched for, in case the routine is found
- You can doubleclick on the rectangle representing your method to focus only on this method, and from your you'll have a better overview of the routine in question
hope this helps
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Wow, never seen that CLR profiler before. That is a great tool. Thanks.
Simon
|
|
|
|
|
hi guys, I am almost desperate about this, I was trying for whole day, I want to set the initial direcotory for OpenFileDialog on FTP folder. How I can do that please help me. If someone knows some example it will be great to share with me. Thx Ahead
|
|
|
|
|
Hi,
I have a custom class wich contains a string property calles FilePath.
When I use this class in my PropertyGrid I want to be able to fill the FilePath with help of a File Dialog.
How do I do this??
|
|
|
|
|
|
This would be perfect if i could get it to work .
But the problem is my "System.Windows.Forms.Design" doesn't contain a "FileNameEditor".
I'm I still doing something wrong?
Extra info.
I'm working with the .net 3.5 framework.
modified on Friday, June 27, 2008 3:15 AM
|
|
|
|
|
I've allready found it.
You have to add the System.Design.dll as a reference.
Thanks.
|
|
|
|
|
=========================================================================================
MailMessage msgMail = newMailMessage("ngoc_kha@gmail.com", "ngoc_kha@yahoo.com");
msgMail.Subject = (" Công Ty Ð?i Nam Kính Chào Quý Khách");
msgMail.Body = ("hi?n nay công ty chúng t?i dang ");
SmtpClient s = newSmtpClient();
s.Host = "smtp.gmail.com";
NetworkCredential basicAuthenticationInfo = newNetworkCredential("ngoc_kha@gmail.com", "ttth1278");
s.UseDefaultCredentials = false;
s.Credentials = basicAuthenticationInfo;
s.EnableSsl = true;
s.Send(msgMail);
================================================================================
error
"The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required."
are you help me??? sorry my english isn't well
|
|
|
|
|
I am sure someone wrote an article to do that, right here in CodeProject. Just search for "gmail SMTP".
|
|
|
|
|
Hi,
I am tryiing to update one of the settings inside the app.config file.
This is the code I am trying to run. No error is produced by nothing gets updated. I think the problem is to do with appsettings because the code does not find appSettings inside the app.config
Any thoughts please?
public static void WriteSetting(string key, string value)
{
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings.Add(key, value);
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
}
---------------
app.Config file data:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="DataAccess.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<DataAccess.Properties.Settings>
<setting name="MailTo" serializeAs="String">
<value>myMailAddress</value>
</setting>
<setting name="Folder" serializeAs="String">
<value>C:\Work\Developments</value>
</setting>
<setting name="Filter" serializeAs="String">
<value>*.*</value>
</setting>
<setting name="EnableMonitor" serializeAs="String">
<value>True</value>
</setting>
<setting name="MailServer" serializeAs="String">
<value>smtpinternalMailServer</value>
</setting>
<setting name="MailFrom" serializeAs="String">
<value>myMailAddress</value>
</setting>
</DataAccess.Properties.Settings>
</applicationSettings>
</configuration>
|
|
|
|
|
|
Is it possible to see what the problem is in the code already posted please?
Thanks
|
|
|
|
|
Hi all,
I have an image on my report. How can I set the image value from my C# code, i.e how does one get hold op the properties of the specific object on the report?
Many thanks in advance
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
modified on Thursday, June 26, 2008 8:38 AM
|
|
|
|
|
hi,
i have an xml document like this
<Test xmlns="">
<Info>
<ReturnParameter>
<name>PkidID</name>
<value>1<value>
<name>CustNo</name>
<value>A1258</value>
</ReturnParameter>
</Info>
<Status>1</Status>
<Message>Not Found</Message>
</Test>
i need to fill this to a dataset so that in can be binded to a gridview. please help me in how to bind this xml to a dataset
|
|
|
|
|
You can use Dataset.ReadXml.
|
|
|
|
|
i tried with that and got an error 'Illegal characters in path.', and please check with the xml structure that i have given.
so i the dataset the values will be like this
statiid custNo status value
--------- ------ ------ -----
1 A1258 1 not found
and to your knowledge the xml data is in a string variable in this format.
thanks & regards
karthi
|
|
|
|
|
Just as the subject says... which is the best way of knowing when a file is locked by another application? the only way I know to do this is trying to open and work with the file and catching the exception, and wonder if there is any other faster method.
Plus if I'd wish to work with several files at once where each one depends on the previous one I'd have to use nested try...catch blocks, and you know, I appreciate my eyes.
|
|
|
|
|
|
I guess you are telling me to plain use a FileSystemWatcher, because using it together with a service is something just not feasible when any file on the computer may be open.
Will this work? Always used FileSystemWatcher for being aware about changes in a file or folder since it starts working, I didn't know it could give information of the current status of a file. Anyway, wouldn't this need a lot of resources for just trying to open a file?
Well, I'll give it a look when I return at home.
|
|
|
|
|
When you open the filestream, request non shared access, it will fail then, and not later.
|
|
|
|
|
Well, that's what I'm already doing.
I'd like to know if there is some function (I don't care if it isn't a managed one) that directly tells if a file is locked by another application, that way I wouldn't need to use nested try...catch blocks.
|
|
|
|