Click here to Skip to main content
15,896,118 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Read Text File from URL Pin
albCode10-May-06 10:30
albCode10-May-06 10:30 
Questionreally IMPOSSIBLE? Pin
innocent7310-May-06 4:18
innocent7310-May-06 4:18 
AnswerRe: SmallDateTime Hell.. Pin
J4amieC10-May-06 4:26
J4amieC10-May-06 4:26 
GeneralRe: SmallDateTime Hell.. Pin
innocent7310-May-06 4:35
innocent7310-May-06 4:35 
GeneralRe: SmallDateTime Hell.. Pin
innocent7310-May-06 4:43
innocent7310-May-06 4:43 
GeneralRe: SmallDateTime Hell.. Pin
Bhasker Pinninti10-May-06 6:10
Bhasker Pinninti10-May-06 6:10 
GeneralRe: SmallDateTime Hell.. Pin
innocent7311-May-06 1:45
innocent7311-May-06 1:45 
AnswerNo it's easy... Pin
Steve McLenithan11-May-06 7:09
Steve McLenithan11-May-06 7:09 
You really need to be using parameters instead of concatenated strings. Not only is it faster, but it's safer.

Since you only had 3 fields in your insert statement, that's all I put in this example

SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Your_Connection_String_Here";
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = @"INSERT INTO [SupplierOperations ] VALUES (@orderNum, @modelNum, @other);"; // <-- paramaters here named whatever you want.

SqlParameter p1 = new SqlParameter();
p1.SqlDbType = SqlDbType.NVarChar; // <-- didn't bother guessing the db type for this field or the next one
p1.ParameterName = "@orderNum";
p1.Value = txtOrderNum.Text;

SqlParameter p2 = new SqlParameter();
p2.SqlDbType = SqlDbType.NVarChar;
p2.ParameterName = "@modelNum";
p2.Value = txtModelNum.Text;

SqlParameter p3 = new SqlParameter();
p3.SqlDbType = SqlDbType.SmallDateTime; // <-- this is where ado.net automatically converts the value provided to smalldatetime.
p3.ParameterName = "@other";
p3.Value = TextBox1.Text;

cmd.Parameters.AddRange(new SqlParameter[] { p1, p2, p3 });

cmd.ExecuteNonQuery();


Found on Bash.org
[erno] hm. I've lost a machine.. literally _lost_. it responds to ping, it works completely, I just can't figure out where in my apartment it is.


-- modified at 13:11 Thursday 11th May, 2006
Questionnot moveing Pin
ptvce10-May-06 4:18
ptvce10-May-06 4:18 
Questionnot moved Pin
ptvce10-May-06 4:16
ptvce10-May-06 4:16 
AnswerRe: not moved Pin
albCode10-May-06 10:33
albCode10-May-06 10:33 
GeneralRe: not moved Pin
cheeken2u10-May-06 16:54
cheeken2u10-May-06 16:54 
GeneralRe: not moved Pin
_AK_10-May-06 18:39
_AK_10-May-06 18:39 
GeneralRe: not moved Pin
albCode10-May-06 19:32
albCode10-May-06 19:32 
GeneralRe: not moved Pin
ptvce10-May-06 22:29
ptvce10-May-06 22:29 
QuestionSet Iframe width Pin
Insane D10-May-06 3:42
Insane D10-May-06 3:42 
AnswerRe: Set Iframe width Pin
leckey10-May-06 4:25
leckey10-May-06 4:25 
AnswerRe: Set Iframe width Pin
Insane D11-May-06 2:27
Insane D11-May-06 2:27 
QuestionBinding objectdatasource to an object Pin
moazzamahmed10-May-06 3:40
moazzamahmed10-May-06 3:40 
AnswerRe: Binding objectdatasource to an object Pin
minhpc_bk10-May-06 15:24
minhpc_bk10-May-06 15:24 
QuestionUnable to disable caching Pin
Mornz10-May-06 3:35
Mornz10-May-06 3:35 
AnswerRe: Unable to disable caching Pin
chinnasrihari10-May-06 3:42
chinnasrihari10-May-06 3:42 
GeneralRe: Unable to disable caching Pin
Mornz10-May-06 4:06
Mornz10-May-06 4:06 
Questionsmtp port Pin
Bhasker Pinninti10-May-06 2:38
Bhasker Pinninti10-May-06 2:38 
AnswerRe: smtp port Pin
chinnasrihari10-May-06 2:59
chinnasrihari10-May-06 2:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.