|
Dear Friends,
I stuck at a point, to download a file from HTTPS site.
I have a secured web site https/www.mySite.com/.
I havent any idea which Certificate that server is using.
I just want to down load a file from that site.
For that I have written the code:
private static bool ValidateRemoteCertificate(<br />
object sender,<br />
X509Certificate certificate,<br />
X509Chain chain,<br />
SslPolicyErrors policyErrors<br />
)<br />
{<br />
<br />
if (policyErrors == SslPolicyErrors.None)<br />
return true;<br />
else<br />
return false;<br />
<br />
<br />
));<br />
<br />
but it always shows the error "System.Net.Security.SslPolicyErrors.RemoteCertificateNameMismatch"
and if i forcefully return true it works fine...
what is proper solution??????
thnaks in advance
|
|
|
|
|
If you are happy to disable the checking of the certificate (not recommended) then use something like
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(
delegate
{
return true;
});
If you are using a WebClient for instance, it should go just before you do the call that will connect (i.e. client.UploadFile(), client.UploadValues(), etc)
|
|
|
|
|
Hi
please check my coding and guide me why record not insert
my coding is
OdbcConnection cn;
OdbcCommand cmd;
OdbcDataReader odr;
string MyString;
MyString = "Select empid , sysdte from timemgmt";
if (radioin.Checked == true)
{
cn = new OdbcConnection("Driver={Microsoft ODBC for Oracle};Server=orcl8i;UID=itehad;PWD=creative;");
cmd = new OdbcCommand(MyString, cn);
cn.Open();
cmd.CommandText = "Select empid , sysdte from timemgmt where empid = '"+textBox1.Text+"' and sysdte ='"+label19.Text+"'";
//MessageBox.Show("Connected");
//cmd.CommandText = "select empid,sysdteinsert into timemgmt values('" + textBox1.Text + "','" + label19.Text + "','" + label18.Text + "','" + label18.Text + "')";//,'" + label18.Text + "','" + label18.Text + "')";
//MessageBox.Show(cmd.CommandText);
//cmd.ExecuteNonQuery();
odr = cmd.ExecuteReader();
while (odr.Read())
{
if (textBox1.Text == (odr["empid"].ToString()) && label19.Text == (odr["sysdte"]).ToString())
{
MessageBox.Show("You Already IN this ID Today");
}
else
{
cmd.CommandText = "insert into timemgmt values('" + textBox1.Text + "','" + label19.Text + "','" + label18.Text + "','" + label18.Text + "')";
}
}
cn.Close();
|
|
|
|
|
It would be helpful if you posted the error generated!
This assumes there are only 4 field in the table.
cmd.CommandText = "insert into timemgmt values('" + textBox1.Text + "','" + label19.Text + "','" + label18.Text + "','" + label18.Text + "')";
If there are more you need
cmd.CommandText = "insert into timemgmt (field1, field2, field3, field4) values('" + textBox1.Text + "','" + label19.Text + "','" + label18.Text + "','" + label18.Text + "')";
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I give feild name like this
cmd.CommandText = "insert into timemgmt values(empid,sysdte,intime,outtime)('" + textBox1.Text + "','" + label19.Text + "','" + label18.Text + "','" + label18.Text + "')";
no record Insert
And no error show
please guyz help me
|
|
|
|
|
There is a error in insert statement
try this
cmd.CommandText = "insert into timemgmt(empid,sysdte,intime,outtime) values ('" + textBox1.Text + "','" + label19.Text + "','" + label18.Text + "','" + label18.Text + "')";
Regards,
Karthik K...
|
|
|
|
|
No my problem is not solve
ok tell me how i search record in oracle database if record find record not save else save record
i code this for search record
cmd.CommandText = "Select empid , sysdte from timemgmt where empid = '"+textBox1.Text+"' and sysdte ='"+label19.Text+"'";
then i create condition like this
while (odr.Read())
{
if (textBox1.Text == (odr["empid"].ToString()) && label19.Text == (odr["sysdte"]).ToString())
{
MessageBox.Show("You Already IN this ID Today");
}
else
{
cmd.CommandText = "insert into timemgmt values(empid, sysdte, intime, outtime)('" + textBox1.Text + "','" + label19.Text + "','" + label18.Text + "','" + label18.Text + "')";
cmd.ExecuteNonQuery();
}
|
|
|
|
|
mjawadkhatri wrote: cmd.CommandText = "Select empid ,sysdte from timemgmt where empid = '" + textBox1.Text + "' and sysdte ='" + label19.Text + "'";
your search query is ok.
After that use like this way,
if(odr.read())
{
MessageBox.Show("You Already IN this ID Today");
}
else
{
cmd.CommandText = "insert into timemgmt empid, sysdte, intime, outtime) values('" + textBox1.Text + "','" + label19.Text + "','" + label18.Text + "','" + label18.Text + "')";
cmd.ExecuteNonQuery();
}
Try the above code.Use the Breakpoints and try to rectify where the error comes.
Regards,
Karthik K...
|
|
|
|
|
I already told you to use the 'code block' tags when posting code
(see here[^] )
I also already told you to use parameters (to prevent sql-injunctions). Not only are they safer they will also prevent a lot of errors.
|
|
|
|
|
Where to start?
- Give your variables meaningful names. At a glance, what does textBox1 do?
- Your code is wide open to a SQL Injection attack. You need to look into using parameterised queries here.
- Your insert statement does nothing. You create the command text and then close the connection - you need to execute the command using cmd.ExecuteNonQuery();
- You have no exception handling. What happens if you can't connect the database, for instance?
If you had bothered to debug your code, you would have found the problem out in an instant. Learning to debug is one of the most valuable lessons you can master as a developer, and you should learn how to do it before too much longer.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hello Everyone,
I wrote an application which send and receive data from a pinpad(device with RS-232 which use serial port) and i start testing the application, when i finised testing the application on my computer, I upload it to the server machine to do another test but when I run the application from client computers it does not recognize the pin pad, but when I run the application from my computer it works properly. My question is that is there any way I can access the pin pad remotely?
Thanks
|
|
|
|
|
Liya Kebede wrote: is there any way I can access the pin pad remotely?
I dont think so : I think you need to implement a tcp/ip network layer to sit between the serial port and the network and send it commands from your application.
We do this with eftpos devices - they are sent instructions from a centralised gateway via tcp/ip, and the client on the pc interfaces to the com port (via an activex control supplied by the eftpos company) .. (ok, so there's an activex control there, but it doesnt really matter that much)
There are commercial companies out there that offer pre-made toolkits to do this - just a quick search gives :-
http://www.serial-port-communication.com/serial-over-tcpip/[^]
http://www.fabulatech.com/network-serial-port-kit.html[^]
oh .. a thought comes to mind, maybe citrix can do it, but thats a different paradigm
'g'
|
|
|
|
|
Hi,
when you start the application on your computer, it doesn't matter where the exe-file is located, the code runs on your computer with it's local hardware!
When you need to communicate with a remote serial port, you need to run on the remote computer an application, e.g. windows service, and communication with that application (e.g. Sockets)
Kind regards
|
|
|
|
|
Hi,
Does it help if i use socket programming?
Thanks Again
|
|
|
|
|
Hi,
I don't think so. A normal com port is not reachable from remote without any local program.
But you can write a simple program which sends every received byte to com port. backwards might be a bit difficultier, because you should use DataReceived event from com port on server. but what is life without any chalenge?
good luck, bye
|
|
|
|
|
Hi guys,
I was able to access the serial port remotely but when i change the serial port to usb it does not working. Is there any way i can access the pinpad using usb ports or is there a library which work like serial port in C#.
Thanks Again
Liya
|
|
|
|
|
|
Hello all,
I have a dll from a card reader...
I encapsulate this dll into a ASP.NET Class Library...
and compile it into my own CardReaderWriter.DLL.
this Class library has methods..
the card reader will be connected in client computer..
Since it's on client side, i can not use ASP .NET to call and use the Class Library
Do I need to Copy this dll to client machine and register it .
How do i create an object of this on client side to access the methods ...
i tried using javascript new ActiveXObject() method but its giving me a runtime error "The system cannot find the file specified"
i even tried the object tag but gives me the error that object doesnot support this property
Note:- i have already compiled and registered the Dll on client machine to be safe but still not able to do it.
plz guide me to the right direction.
if possible plz provide sample codes and links to articles.
thanx in advance
mukeshmkg
|
|
|
|
|
Hello
I have a question concerning printing out source code (in my case VBScript Source) with highlighted syntax, line numbering etc.
I'm actually working on a printer routine.
It should be possible to print out a "VBScript Code Snippet".
How is it possible to print out that code a syntax highlighted way?
Is there already a .NET standard method to do this?
Or do I have to parse every command to color it?
Thanks in advance for any advices
|
|
|
|
|
Hi
i populate dataset with data from uif table and one of the colum is marriage status which is integer so i want to you case statement where for example if marriage_status is 1 then it has to display single on detailsview.
here is my code
int MarriageStatus = (int)dataset.Tables["uif"].Rows[0]["marriage_stat"];
string status = Convert.ToString(MarriageStatus);
switch(MarriageStatus){
case 0:
status="Single";
break;
case 1:
status="Single";
break;
case 2:
status = "married";
break;
case 3:
status="Widowed";
break;
case 4:
status="Divorced";
break;
}
Mamphekgo
|
|
|
|
|
And you problem is?
You could have
Case 0:<br />
Case 1:<br />
status = "Single"<br />
break;<br />
case 2:
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hello All
I`m very new to the programming so this might be easy question to all of you, i`m hoping someone can help me out.
So i`m trying to write very easy program in windows form but i have encountered the problem.
lets say that i have an event on the button1 (CLICK) which should pick up a random number and hold it in the memory unless i click it again to change it. My problem is that i cannot figure out how to use this variable which has been set up in the first place with another event button2(Click) which will use this variable and do other task with using int previously declared. Short example:
public void Random_Click(object sender, EventArgs e)
{
Random myRandom = new Random();
int myNumber = myRandom.Next(1,10);
}
public void Button2_Click(object sender, EventArgs e)
{
MessageBox(myNumber.ToString());
}
This will not work and i cannot find the way to get it right
plese help !!!
|
|
|
|
|
one way is to declare a global variable try this:
public int myNumber;
public void Random_Click(object sender, EventArgs e)
{
Random myRandom = new Random();
myNumber = myRandom.Next(1,10);
}
public void Button2_Click(object sender, EventArgs e)
{
MessageBox(myNumber.ToString());
}
hope this helps
|
|
|
|
|
Hello still nothing cannot solve this problem, so what i tried is i tried declare variable as a (public int nameOfInteger) just before the method, in the begining oif the class and everywhere else. Still confused
thats my code
namespace ExerciseInt
{
public partial class Form1 : Form
{
int newNumber;
public Form1()
{
InitializeComponent();
}
public void button1_Click(object sender, EventArgs e)
{
Random myRandom = new Random
myNumber = myRandom.Next(1,10);
}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show(myNumber.ToString());
}
}
}
so when i click button1 variable should be set up and when click button2 i would like to see this variable in the message box.
looking forward to hear from you.
|
|
|
|
|
Are you using some IDE? It would be helpful if you could give some error reports and I think I could think of one. Now, that would be newNumber and myNumber. Are those supposed to be the same? I think so.
I came, saw, and then coded.
|
|
|
|