|
private void btnSave_Click(object sender, EventArgs e)
{
string Strconn = "Server = local; User ID = sa; Password = computer; Initial Catalog = FingerData";
string Strcomm = "INSERT INTO Employee VALUES(";
Strcomm += "'"+txtFinger.Text+",'";
Strcomm += "'"+txtPrename.Text+"','";
Strcomm += "'"+txtFname.Text+"','";
Strcomm += "'"+txtLname.Text + "','";
Strcomm += "'"+txtNname.Text + "','";
Strcomm += "'"+picEmp.Image + "',";
Strcomm += "'"+txtAge.Text + ",";
Strcomm += "'" + "CONVERT(DATETIME,'" + txtBirth.Text + "', 102),'";
Strcomm += "'"+txtAddress.Text + "','";
Strcomm += "'"+txtDepartment.Text + "',";
Strcomm += "'"+txtSalary.Text + ",'";
Strcomm += "'"+txtHtel.Text+ "','";
Strcomm += "'"+txtMtel.Text + "','";
Strcomm += "'"+txtEmail.Text+"','";
Strcomm += "'"+txtPassword.Text + "')";
SqlConnection SQLconn = new SqlConnection(Strconn);
SqlCommand SQLcomm = new SqlCommand(Strconn, SQLconn);
try
{
SQLconn.ConnectionString = Strcomm;
if (SQLconn.State == ConnectionState.Open)
{
SQLconn.Close();
}
SQLconn.Open();
SQLcomm.CommandType = CommandType.Text;
SQLcomm.CommandText = Strcomm;
SQLcomm.Connection = SQLconn;
SQLcomm.ExecuteNonQuery();
}
catch (Exception Error)
{
MessageBox.Show("ไม่สามารถเพิ่มข้อมูลได้เนื่องจาก !!!!! " + Error.Message, "ข้อผิดพลาด", MessageBoxButtons.OK);
}
}
lmjojopjkopkop
|
|
|
|
|
Standard question #2:
What error message do you get?
---
b { font-weight: normal; }
|
|
|
|
|
Guffa wrote: Standard question #2:
What's Standard Question #1?
As of how to accomplish this I wouldn't have a clue at the moment and I'm too lazy to google it
|
|
|
|
|
Ed.Poore wrote: What's Standard Question #1?
Standard question #1:
What do you mean by "not working"?
---
b { font-weight: normal; }
|
|
|
|
|
I should have seen that coming
Maybe you should write an article of these standard questions?
As of how to accomplish this I wouldn't have a clue at the moment and I'm too lazy to google it
|
|
|
|
|
This code is begging for a SQL injection attack. You should read up on what that means, your app is ripe for abuse.
if (SQLconn.State == ConnectionState.Open)
{
SQLconn.Close();
}
SQLconn.Open();
Why ?
As someone else said, we need to know what the error is. Your query may be malformed, but I'm not going to trawl through it to see. However, that's a SQL Server connection string, you should be using stored procs instead of dynamic SQL.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
I am working with Visual Studio 2005 (.NET 2.0) with C# for Windows Application.
When I dragged and dropped a Table from Data Source Explorer, I found that Binding Navigator was also added to the form automatically with "Save Button". After that I had to delete the Binding Navigator Control from the form for some reason. Later whenever I drag and drop a new data table from the data source, Binding navigator is no more added to the form. I had to add that manually from the control tool box. That is also fine, but the later Binding Navigator Control Doesn't contain "SAVE" button. How can I get that "Save" Button back to Binding Navigator Control ?
Thanks
Emran
|
|
|
|
|
Just add the button to the ToolStrip and then look at the BindingNavigator, there'll be a property to do with the which ToolStripButton is the Save Button, just set the appropriate one.
As of how to accomplish this I wouldn't have a clue at the moment and I'm too lazy to google it
|
|
|
|
|
Hi,
Thanks for your reply.
I tried with your suggession, but I did not see any property in binding navigator for Save button,. But I found for ADD, Delete, First, Last etc..
Is there any reason that the SAve button item may not be asked by the property editor of Binding navigator ?
|
|
|
|
|
I suggest creating a new project just to see what code is generated, you can then duplicate that across to your project.
Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9
Ed
|
|
|
|
|
Hi,
I have some questions regarding some security issues.
1)
We are encrypting different fields in our MySql database. This is done in the C# code. We are going to start encrypting more fields but the problem is then to run the queries (sorting and so on). What is the best approach here - is the best way to use the encrypt/decrypt methods in the MySql instead or how do you usually do it? Database layer or application layer?
2)
What is the best obfuscating tool for .NET? Do they really protect against code decompiling?
3)
How do you store a encryption key in the best way? It doesn't feel secure to store it in the source code, but how do you protect it in the best possible (safest) way?
Thankful for some help from people that have experience in making secure systems in .NET.
// regards Patrik
|
|
|
|
|
1) - Sorry I'm not a database whiz, I can do simple stuff but you'd be better off getting advice from someone else.
2) - Don't know about which is the best, Preemptive seem to have a fairly good name. As to whether they prevent decompiling, in short they cannot. But what they do do is make it difficult for humans to interpret what the program is meant to be doing. Good example of this is Reflector, it will always decompile the code for you but the code will look very convulated although compilable and executable (otherwise it wouldn't run).
3) - One of the more secure ways to do this would be (if you can) generate the encryption key from at runtime, inserting in and / or removing values etc, just make it very difficult to decipher what's going on since anyone who can use Reflector can view your code. Everything is breakable it just depends on how much effort you want people to expend, thus eliminating the "hobbyist" (although they can be a bit more tenecious if they're interested) and curious people. It is unlikely that your code will ever surive pros but you can make it difficult.
As of how to accomplish this I wouldn't have a clue at the moment and I'm too lazy to google it
|
|
|
|
|
Thanks for the answers!
Does anyone else have some ideas regarding these issues?
Regards Patrik
|
|
|
|
|
Hi,
This is my firs Post in this forum.I am in the final Year of Mca.I have assigned a project in C++. The method is that do processing of a movie image with CABAC/CAVLC algorithm.It will be very helpfull if i am given some links for source codes with this algorthm .
Thnaks in advance
|
|
|
|
|
Hi Guys !!
I am totally new to .NET, and I am involved in a conversion project. So I am not sure if this is a silly question to ask.
Anyway, I have to convert the below code from using Enterprise Library 1.1 to Enterprise Library 2.0 ( Jan 2006 release ).
The namespace "sinks" no longer exist, and so do the classes LogSink, ConfigurationView. Could anyone help me with the alternative namespace/classes to achieve the same result ?
---------------------------------------------------------------------------
using Microsoft.Practices.EnterpriseLibrary.Logging;
using Microsoft.Practices.EnterpriseLibrary.Logging.sinks;
namespace SunGard.Adaptiv.AppSupport.Logging.Sinks
{
///
/// Summary description for DebugSink.
///
public class DebugSink : LogSink
{
public DebugSink()
{
}
public override void Initialize(ConfigurationView configurationView)
{
}
protected override void ...(continued)
---------------------------------------------------------------
Rgds,
Gops
|
|
|
|
|
The TraceListener is the replacement for logging sinks. It looks like you're creating a custom sink, so you'll probably want to create an implementation of CustomTraceListener.
Logifusion[^]
If not entertaining, write your Congressman.
|
|
|
|
|
I am currently creating a little C# project which interrogates a webserver (quite alot).
I would like to perform Http-Tunneling in order to have different IPs query the server, but with all the responses sent to me.
Alex Turc has written something which I think is very relevant here:
http://www.codeproject.com/internet/httptunneling.asp
The problem is that this is in C++ (and quite frankly, very incomprehendible/followable to me!)
If anyone has a solution / something similar but in C# I'd appreciate the help so much.
Many thanks!!
Gerry
www.thecrazywebsite.com
-- modified at 10:47 Tuesday 22nd August, 2006
-- modified at 15:24 Tuesday 22nd August, 2006
|
|
|
|
|
Try again to modify the previous post. Sometimes the servers are temporarilly overloaded, and sometimes the update succeds but you get an error message when viewing the thread afterwards.
---
b { font-weight: normal; }
|
|
|
|
|
Yeh thanks it worked.
These servers seem to be overloaded ALOT.
I often come here (to homepage) and get some 505 error or something.
Any clues as to Http-Tunneling in C# ?
Cheers,
Gerry
|
|
|
|
|
Hello,
I have a ComboBox, and I populate it using DataSource property (one ov the column values in the table).
Is there a way of making so that the values are distinct?
Values in my column are repeating, and therefore, they are repeating in the ComboBox.
Thank you
|
|
|
|
|
In short no, what you can do is add them manually and filter out repeated values.
As of how to accomplish this I wouldn't have a clue at the moment and I'm too lazy to google it
|
|
|
|
|
To add on to what Ed said, there are basically 2 ways to do this. Firstly, use distinct on the query you use to get the datasource for the combobox, or secondly, manually go through the datasource and add each unique element to the combobox.items collection.
|
|
|
|
|
Greetz everyone!
I have a question concerning assemblies.
Here is the situation:
I have two assemblies, one is executable and the mdi container, the other one is a library which includes Forms as well.
I referenced the library so I can call it into the mdi container, which works fine.
But I found no way to change variables in the executable out of the library.
For example:
I want to call the Main Form of the library as MDI Child, but just once. When the Form is closed it should be possible to restart it again.
public Library.FormoftheLibrary fotl = null;<br />
privat void StarttheFormoftheLibrary()<br />
{<br />
if (fotl == null)<br />
fotl = new Library.FormoftheLibrary();<br />
fotl.MDIParent = this;<br />
fotl.Show();<br />
}
This works fine as I wrote, but in the FormoftheLibrary I need an EventHandler which sets the variable fotl in the executable on FormClosing back to null.
Also I would need to use classes in the executable in the library.
I tried to reference it as well, but VS tells me, that circledependencies (I think that´s the correct english term) aren´t allowed.
I tried to forward the Form to the library, but it doesn´t work as well (which makes sense, but doesn´t help me out).
in the executable:
fotl = new Library.FormoftheLibrary(this);
in the library:
void FormoftheLibrary(Executable.MainFormoftheExecutable form)<br />
So how to tell the library, that it can use the variables of the executable?
Thx in advance,
ezazazel
-- modified at 14:26 Tuesday 22nd August, 2006
|
|
|
|
|
The simplest solution would be in to pass a reference to the MainForm in the constructor of the
Library.FormoftheLibrary.<br /> E.g:
public class FormoftheLibrary : Form
{
private MainForm mainForm;
public FormoftheLibrary(MainForm mainForm)
{
this.InitializeComponent();
this.mainForm = mainForm;
}
} Then in the calling routine:
public fotl = new Library.FormoftheLibrary(this);
private void StarttheFormoftheLibrary()
{
if (fotl == null)
{
fotl = new Library.FormoftheLibrary(this);
fotl.Show();
}
}
Then in the FormClosing event of the Library form:
protected overrides void OnClosing(CancelEventArgs e)
{
this.mainForm.fotl = null;
} Hope that helps.
As of how to accomplish this I wouldn't have a clue at the moment and I'm too lazy to google it
|
|
|
|
|
Hi Ed.Poore!
Thx for your reply, but I experienced some problems with your suggestion.
Your proposal works fine as long as I´m in the same assembly, but not in this case, where I have more assemblies in my solution.
public class FormoftheLibrary : Form<br />
{ <br />
private MainForm mainForm; <br />
public FormoftheLibrary(MainForm mainForm)
{<br />
this.InitializeComponent(); <br />
this.mainForm = mainForm; <br />
}}
As I wrote in my initial message, I cannot pass the MainForm (from the first and executable assembly)
to the variable mainForm (in the second assambly which is a library) as VS tells me
"the type or namespace name MainForm cannot be found..." and that I´m missing the reference. But I cannot reference it due to the circledependencies, as the dependency is already set to the executable assembly.
Anyway thanks a lot for your time, maybe you have another suggestion.
Thanks in advance,
ezazazel
|
|
|
|