|
hi !
I want to save the value of date with the using DateTimePicker Control in a sql table with the date Format .
...<br />
try{<br />
strSQL ="update mytable set name='"+txtName.Text+ "',mydate='"+DateTimePicker1.???? ......
Any guid is very appereciated.
Regards
s_mostafa_h
-- modified at 9:30 Wednesday 22nd February, 2006
|
|
|
|
|
string commandText = "UPDATE mytable SET name = @name, mydate = @date";
SqlCommand command = new SqlCommand(commandText, myConnection);
command.Parameters.Add(new SqlParameter("@name", txtName.Text));
command.Parameters.Add(new SqlParameter("@date", dateTimePicker1.Value));
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Connor's Christmas Spectacular!
Judah Himango
|
|
|
|
|
I Wrote this :
try{<br />
strSQL ="update mytable set name='"+txtName.Text+ "',mydate='"+DateTimePicker1.Value+"'";<br />
cnSQL = new SqlConnection(Connectionstring);<br />
cnSQL.Open();<br />
cmSQL = new SqlCommand(strSQL, cnSQL);<br />
cmSQL.ExecuteNonQuery();<br />
cnSQL.Close();<br />
cmSQL.Dispose();<br />
cnSQL.Dispose();<br />
} <br />
catch(SqlException e)<br />
{<br />
MessageBox.Show(e.Message, "Error");<br />
} But I have this Error :
syntax error converting datetime from character string
the type of mydate field is datetime .
please guide me !
thanks
s_mostafa_h
|
|
|
|
|
mostafa_h wrote: strSQL ="update mytable set name='"+txtName.Text+ "',mydate='"+DateTimePicker1.Value+"'";
Don't do that. You're opening yourself up to SQL injection attacks[^]. I showed you the proper way to do it in my last reply (by using SqlParameter objects). If you follow that course of action, you won't get the error.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Connor's Christmas Spectacular!
Judah Himango
|
|
|
|
|
thanks of your guide !
REGARDS ,
s_mostafa_h
|
|
|
|
|
mostafa_h wrote: Any guid is very appereciated
{DB618332-94FC-4171-BFCC-BA654F5EED58}
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
Michel Prévost wrote: {DB618332-94FC-4171-BFCC-BA654F5EED58}
{DB618332-94FC-4171-BFCC-BA654F5EED58}
Any guide is very appreciated .
excuse me for my poor english .
s_mostafa_h
|
|
|
|
|
No problem, english is not my first language either. I just hope you are not angry at me, I couldn't resist doing the joke.
I guess you know what a GUID is...
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
-- modified at 13:26 Wednesday 22nd February, 2006
|
|
|
|
|
ofcourse , there are a lot of expression that i don't know the meaning it .
in any case , I'm always . Now it's 01:44:50 o'clock (midnight).
s_mostafa_h
|
|
|
|
|
Hi evry body
How I can Use Thread In my program to run a Methode Continual with a littel Sleep.?
Do Methode needs to delegate for using in Threading?
---------------------
Areff Bahrami(KAVEH)
Areff.HB@Gmail.com
---------------------
|
|
|
|
|
|
Areff,
If its a windows app use the backgroundWorker control, alternatively :
Using System.Threading;
Thread myThread = new Thread(new ThreadStart(myMethod));
Thread.Sleep(1000); //Sleep for 1 second
HTH
Jonny
|
|
|
|
|
Areff,
If its a windows app use the backgroundWorker control, alternatively heres a code snippet :
--
Using System.Threading;
Thread myThread = new Thread(new ThreadStart(myMethod));
Thread.Sleep(1000); //Sleep for 1 second
--
HTH
Jonny
Jonny
|
|
|
|
|
Jonny, thank you for help
---------------------
Areff Bahrami(KAVEH)
Areff.HB@Gmail.com
---------------------
|
|
|
|
|
Hi Evry body.
I want to Search a Struct in file .
for this problem i use a while loop and Seek Statment but i have a problem with Seek Origin ?
I want Information about Seek and Origin Please
---------------------
Areff Bahrami(KAVEH)
Areff.HB@Gmail.com
---------------------
|
|
|
|
|
What particular information about them do you want, that the documentation does not tell you?
Or, how about some code to show us where you are having problems in understanding how to use Seek on a stream?
|
|
|
|
|
[Serializable()]<br />
public struct Record<br />
{<br />
public string name;
public string Lname;
public int Id;
public int Lid;
public byte Grade;
public string Lsname;
}<br />
<br />
<br />
public static Record Load(string Fname)<br />
{<br />
Stream InStream = File.OpenRead(Fname);<br />
BinaryFormatter DeSerializer = new BinaryFormatter();<br />
<br />
<br />
Record LoadClass = (Record)(DeSerializer.Deserialize(InStream));<br />
InStream.Close();<br />
return LoadClass;<br />
}
I want search in file to find a special struct(record)
I hope you understand me.
---------------------
Areff Bahrami(KAVEH)
Areff.HB@Gmail.com
---------------------
|
|
|
|
|
Hi evry body
how i can download a web page from internet with a C# Application
---------------------
Areff Bahrami(KAVEH)
Areff.HB@Gmail.com
---------------------
|
|
|
|
|
|
Perhaps this[^] article will help? If you also want to parse the downloaded content, see this[^] article.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
string URL = "http://www.somepagegoeshere.com"; //the url
HttpWebRequest PageRequest = (HttpWebRequest)WebRequest.Ceate(URL); //some fun web stuff
WebResponse PageResponse = PageRequest.GetResponse();
StreamReader r = new StreamReader(PageResponse.GetResponseStream()); //here we go
string theDownloadedPage = r.ReadToEnd(); //and it's downloaded
r.Close();
I didn't test it but it looks right.
|
|
|
|
|
oh, and you are using System.Net;
|
|
|
|
|
Thank Guys for your help...
---------------------
Areff Bahrami(KAVEH)
Areff.HB@Gmail.com
---------------------
|
|
|
|
|
hai i want to check whether the given id exists in the data base ,if exists it should proceed if not it should give error message.its a window based c# application.iam using comand reader but its giving error.
|
|
|
|
|
Can we get the Edit,Delete,Add buttons in the grid of the windows application?
I mean, as soon as i am clicking on any of the buttons, it is getting redirected to another form.
But, I want the actions to be performed in the same grid.
If it is possible please send solution for my problem.
|
|
|
|