|
thanx graus.
i have checked login,now i want loginid n password which user enters in textboxes into another database.
i m a student of computer science doing project work.
i m trying this code, but no effect :
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=PROGRAMER;Initial Catalog=statusutility;Integrated Security=True");
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
con.Open();
cmd.CommandText = "INSERT INTO login(userid,password) VALUES (@pUsername,@pPswd)";
SqlParameter p1 = new SqlParameter("@pUsername", SqlDbType.VarChar, 50);
p1.Value = textBox1.Text;
cmd.Parameters.Add(p1);
SqlParameter p2 = new SqlParameter("@pPswd", SqlDbType.VarChar, 50);
p2.Value = textBox2.Text;
cmd.Parameters.Add(p2);
con.Close();
}
can u plz help on it?
Thank You.
Nekshan.
|
|
|
|
|
This code cannot have any effect, because you never execute the query. Insert cmd.ExecuteNonQuery(); before you close the connection.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Not often I see my name in a header...
If you want to get someone's attention, post again in the thread where you're talking to them. That way, I would have got an email.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi, any idea on why VS2005/C# always runs a project file when I try to run an existing solution file?
Say... I double clicks on a solution file. But when the VS2005 runs, the root in the Solution explorer appears to be its project file. Please help.
Thank you very much.
KiT
-- Never wait for a chance to come, Believe in your own potential and go get it! --
|
|
|
|
|
Sorry... I got it. The option to show the solution file is not checked -_-"
KiT
-- Never wait for a chance to come, Believe in your own potential and go get it! --
|
|
|
|
|
Hello dear gurus,
I'd like to know how I can detect in C# if the default instance of MS SQL Server is installed???
Is there a way to do that???
Can someone show me a code snipet or something please?
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
The default instance on a machine can be reached by connecting to localhost. So, you can try to connect and see what happens. But, if it's no running and not set to autostart, this will fail.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Requirement:
I want to create an application, which should be able to create a file, with the file extension be specified by me. And, when i double click to open that file, it should open it's content in that application. How can this be achieved? ( like word,excel..etc)
Code so far:
For example.. I have created a application with a Richtextbox control to display data,buttons to create a new file, openfile,savefile and to exit. And let my file extension be ".gun".
Time to Answer:
Now, what happens is i create new file, save(savefiledialog) it with .gun extension. This files gets opened when i open it using 'open(openfiledialog) button' which is present in my application. But when i double this file (which is placed on desktop) it opens only the application and not with the content.? How can i get it with the content when the file is double clicked?
|
|
|
|
|
Look for method "Main" in your application.
If you have no parameters in it "Main()" then change it to "Main(string[] args)".
If you double-click .gun file, then it is like calling using command prompt:
MyApplication.exe myFile.gun
Just take your .gun file in "args" variable.
|
|
|
|
|
Or just call Environment.GetCommandLineArgs()
|
|
|
|
|
You will need to associate the file extension *.gun with your application - the article http://support.microsoft.com/kb/185453 describes for VB but its basicallyde sticking some info in the registry...
|
|
|
|
|
Hi, When i use Main(string[] args) or Environment.GetCommandLineArgs;
it shows me the following error.
Error 1 'string' does not contain a definition for 'rtbFile' (Richtextbox instance)
|
|
|
|
|
|
The error is ok now. and i have done main(string[] args) or Environment.GetCommandLineargs..... But still when i double click the created file(file with .gun extension),, it still doesn't contain the content.
|
|
|
|
|
Just for example :
static void Main(string[] args)
{
string fileToOpen = args[0];
}
|
|
|
|
|
I dont get what u try to say. This is my code. Can u suggest with this code....(ofdFile=Openfiledialog,rtbFile=richtextbox)
void btnOpen_Click(object sender, EventArgs e)
{
ofdFile = new OpenFileDialog();
ofdFile.DefaultExt = @"*.gun";
ofdFile.Filter = @"Gun Files|*.gun";
if (ofdFile.ShowDialog() == System.Windows.Forms.DialogResult.OK && ofdFile.FileName.Length > 0)
{
//ofdFile.FileName.
rtbFile.LoadFile(ofdFile.FileName, RichTextBoxStreamType.PlainText);
}
}
|
|
|
|
|
And my main function is in Program.cs file
|
|
|
|
|
pass the args[0] to your form class.
static void Main(string[] args)
{
Application.Run(new Form1(args[0]));
}
For example your form class is Form1.
Then change the constructor to
public Form1(string fileToBeOpened)
{
if(fileToBeOpened != string.Empty)
{
}
}
|
|
|
|
|
It shows me 'IndexOutOfRangeException Unhandled' in program.cs
Application.Run(new Form1(args[0]));
|
|
|
|
|
I think you just COPY and PASTE the code.
You must AWARE OF ERRORS.
You MUST check if
args.Length > 0 // you get the file directly
args.Length == 0 // without file
|
|
|
|
|
Yes it works. Thanks a lot.
|
|
|
|
|
Will get u back if i get more doubts.
|
|
|
|
|
this is kinda difficult to phrase, but how can i let a user insert pics into a c# appliaction, and save it so it will show the next time you run the app?
|
|
|
|
|
You have to build a framework yourself, for how you store the image info ( you can't embedd the images in your actual app ), and to display them. For example, an XML file of image paths, and you then build a list from that, and add pictures to the page dynamically based on this list.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
kindly check my little script and tell me. where am I doing wrong?
When i run this script the error arises :
==>> No connection could be made because the target machine actively refused it
thank you
private void button1_Click(object sender, EventArgs e)
{
IPAddress host = IPAddress.Parse("192.168.0.102"); // <<-- my machine ip
IPEndPoint hostep = new IPEndPoint(host, 8000);
Socket sock = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
try
{
sock.Connect(hostep); // <== Error comes from here
listBox1.Items.Add("Connected.");
}
catch (Exception ex)
{
listBox1.Items.Add("Connection problem is :");
listBox1.Items.Add(ex.Message);
textBox1.Text = ex.Message;
sock.Close();
return;
}
try
{
sock.Send(Encoding.ASCII.GetBytes("testing"));
}
catch (Exception exsoc)
{
listBox1.Items.Add("Problem sending data");
listBox1.Items.Add(exsoc.Message);
sock.Close();
return;
}
sock.Close();
}
|
|
|
|