|
PLEASE use a parameterized query:
SqlCommand cmd = cn.CreateCommand ( "UPDATE tblQLs SET colClosedDate=@colClosedDate ... " ) ;
(Create and add parameters...) (It shouldn't require ToString())
foreach ( ... )
{
(Set parameter values...)
cmd.ExecuteNonQuery() ;
}
Mark-123456789 wrote: too long for the field and i get an error
I'd have to see it.
Mark-123456789 wrote: How can I auto sence the max field width and truncate it.
You'd have to access the schema, which isn't very difficult.
Mark-123456789 wrote: DataViewGrid ie date dd/mm/yyyy
I don't use DataViewGrids so I don't know off hand.
|
|
|
|
|
You wish is my command.
{
SqlConnection cn = new SqlConnection(LoginForm.gb_strConnection);
cn.Open();
// this bit is me trying a work-around-----------------------------
char[] test = new char[15];
txbColPolicyRef.Text = txbColPolicyRef.Text.Trim().ToUpper();
int intLen = txbColPolicyRef.Text.Length;
if (intLen > 15) intLen = 15;
test = txbColPolicyRef.Text.Trim().ToUpper().Substring(0, intLen ).ToCharArray();
// ------------------------------------------------------------
string strCommand = "INSERT INTO tblQLs (colQLID, colCreatedDate, colClosedDate, colErrDate, " +
"colPolicyRef, colCreatedByUserID, colErrDescription, colErrByUserID, " +
"colAppealReason, colAppealUpheld, colFinalActionTaken, colNotes, colUserTeam) " +
"VALUES (" +
"'16', " +
"'x', " +
"'" + test + "', " +
"'" + @txbColCreatedByUserID.Text.Trim().ToUpper() + "', " +
"'" + @cbColErrDescription.Text.Trim().ToUpper() + "', " +
"'" + @txbColErrByUserID.Text.Trim().ToUpper() + "', " +
"'x'," +
"'" + @txbColErrDate.Text.Trim() + "', " +
"'x','x','x','x', " +
"'" + @txbColUserTeam.Text.Trim().ToUpper() + "') ";
SqlCommand cmd = new SqlCommand(strCommand);
cmd.Connection = cn;
cmd.ExecuteNonQuery();
cn.Close();
}
|
|
|
|
|
Maybe check this[^] out.
Particularly my rendition of ExecuteNonQuery and ListColumns.
|
|
|
|
|
My friends i need help about this issue can anyone help me
|
|
|
|
|
You can use Char.IsDigit to see if a character is a digit or other character.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
thanks for your help problem solved
|
|
|
|
|
Hi,
you can use the TryParse() method of int, uint, long, ulong depending on the range you want to support; and some overloads will let you choose options, e.g. allowing thousand separators.
Warning: TryParse() will always fail on an empty TextBox.
similar for reals (float, double), dates, etc.
everything in a TextBox is a string.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
thanks alot problem solved
|
|
|
|
|
|
|
I am tryng to serialize the IP's Server Addresses in my Lan using objects IPHostEntry for getting better the communications with them, later I need that the machines which are going to connect with such Server Serialize and Deserialize the Server's List, but when I try to serialize, both in binary or XML, I receive an error telling me that such object IPHostEntry is not marked as Serializable.
Any suggestion for avoiding this problem
Note: I Create a Dictionary<string, iphostentry=""> containing the name and IP data of every Server and such is the object which I want to Serialize, if the key and value are both strings there is no problem, but when I change to Type IPHOstEntry it does not work.
Regards
|
|
|
|
|
|
0) UPDATE INTO -- nope
1) colErrByUserID = '" + LoginForm.gb_strUserID + "' "; -- very bad idea
|
|
|
|
|
Thanks for that!
Very useful, not!
So what you are really saying is you don't know...
|
|
|
|
|
No, I'm just not going to spoon-feed you. You'll find very few people here who will.
|
|
|
|
|
Thats right you, keep telling yourself that!
|
|
|
|
|
|
I am having an XMl like below
<Details>
<det id=1 name="abc">
</Details>
Now i want to take the above xml as input and to repeat the node
like below using C#
<Details>
<det id=1 name="abc"/>
<det id=2 name="abc"/>
<det id=3 name="abc"/>
</Details>
|
|
|
|
|
|
Rich,
Just I want to repeat the node in aloop by incrementing id.
|
|
|
|
|
I don't understand what your problem is. What code are you using to create the original XML, and what code have you tried to create the repeat items?
|
|
|
|
|
Rich,
In c#.Original xml is a string which I get like below
<details>
<detail id="1" name="x"/>
</details>
I want to take that xml string and to repeat the nodes
foreach xml nodes
<details>
<detail id="1" name="x"/>
<detail id="2" name="x"/>
<detail id="3" name="x/>
</details>
id=2 and id=3 is repeated.want to do it in C#
|
|
|
|
|
That can be easly done using XmlDocument.
You know that class? Have you already tried something or you want us to give all the code to you (that you won't get here, I'm afraid)?
|
|
|
|
|
kurangu wrote: In c#.Original xml is a string which I get like below
Where do you get this from, a const string, XmlReader, TextReader?
kurangu wrote: I want to take that xml string and to repeat the nodes
I ask again, what code have you tried; please help us to understand better what you are actually doing in your code?
|
|
|
|
|
HI,
It's a constant string.
string a =
"<SecDetails><Security PrimarySecID=\"abcd\" Price=\"12\"/></SecDetails>";
XmlDocument originalXml = new XmlDocument();
originalXml.LoadXml(a);
XmlNodeList nodelist = originalXml.SelectNodes("/SecDetails/Security");
foreach (XmlNode xn in nodelist)
{
here I should be able to repeat the node
for (int i=1; i<=10;i++)
{
I am struck here.
}
}
|
|
|
|