Click here to Skip to main content
15,885,757 members
Home / Discussions / C#
   

C#

 
QuestionRe: keystroke monitor Pin
musefan29-Jun-09 2:45
musefan29-Jun-09 2:45 
AnswerRe: keystroke monitor Pin
EliottA29-Jun-09 3:32
EliottA29-Jun-09 3:32 
QuestionConnection Of Database during installing SETUP Pin
rhtbhegade27-Jun-09 20:32
rhtbhegade27-Jun-09 20:32 
AnswerRe: Connection Of Database during installing SETUP Pin
Arindam Sinha27-Jun-09 22:18
Arindam Sinha27-Jun-09 22:18 
QuestionUnable to Save Array values in database Pin
googlejumbo27-Jun-09 19:24
googlejumbo27-Jun-09 19:24 
AnswerRe: Unable to Save Array values in database Pin
Henry Minute28-Jun-09 8:01
Henry Minute28-Jun-09 8:01 
GeneralRe: Unable to Save Array values in database Pin
googlejumbo28-Jun-09 20:24
googlejumbo28-Jun-09 20:24 
GeneralRe: Unable to Save Array values in database Pin
Henry Minute28-Jun-09 21:55
Henry Minute28-Jun-09 21:55 
I think that you have missed the point I was trying to make.
So I'll try again. Smile | :)

First pseudo-code
Setup all parameter(s) *** Note NOT AddWithValue here, just Add. This MUST only be done once, so outside loop ***
start loop
{
  set value of parameter to next value from array *** NOTE this has to be done for each value, so inside loop ***
  execute command to add/insert record
}


now with code from your original post
  <big>sqlInsertCmd.Connection = con;</big> <=== Moved out of loop, only need to do it once, not for each iteration
  // Create all the parameters for your sqlInsertCmd HERE. If there are more parameters, create them here with Add NOT AddWithValue
  <big>SqlParameter ciParam = sqlInsertCmd.Parameters.Add("@cuspIndex", SqlDbType.Int);</big>
  <big>SqlParameter bcParam = sqlInsertCmd.Parameters.Add("@BezierCusp", SqlDbType.Int);</big> // I assume it is an int, but change it to the type you need
  //Using loop to get the all stroke.GetPoint , it will return Array(2dimension) , i want to add all values of array
  //In the Database In the parameter Bezier Cusp ,but it show me the error that"exSql = {"The variable name '@BezierCusp' has already been
  // declared. Variable names must be unique within a query batch or stored procedure."}
  for (i = 0; i <= 100; i = i + 1)
  {
    // Set the values of all parameters here
    <big>ciParam.Value = Convert.ToInt16(stroke.BezierCusps.GetValue(i));</big> // <== I have assumed this should be a different value
                                                                                       // for each row. If not remove this line and restore
                                                                                       // your declaration (above)
    <big>bcParam.Value = stroke.GetPoint(i).X;</big> <== Set the value of the parameter to the next value from the array
    con.Open();
    sqlInsertCmd.ExecuteNonQuery();  <== this stores value to database
    con.Close();
}


I have highlighted code I have changed, or moved. I have had to make some assumptions about data types and how your data works, but I hope you get the idea.

Good Luck! Smile | :)

Henry Minute

Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”

GeneralRe: Unable to Save Array values in database Pin
googlejumbo28-Jun-09 22:22
googlejumbo28-Jun-09 22:22 
GeneralRe: Unable to Save Array values in database Pin
Henry Minute29-Jun-09 6:06
Henry Minute29-Jun-09 6:06 
QuestionLeading zero in hex formatting Pin
Trollslayer27-Jun-09 11:56
mentorTrollslayer27-Jun-09 11:56 
AnswerRe: Leading zero in hex formatting Pin
Christian Graus27-Jun-09 12:01
protectorChristian Graus27-Jun-09 12:01 
AnswerRe: Leading zero in hex formatting Pin
Ed.Poore27-Jun-09 12:01
Ed.Poore27-Jun-09 12:01 
GeneralRe: Leading zero in hex formatting Pin
Christian Graus27-Jun-09 12:18
protectorChristian Graus27-Jun-09 12:18 
GeneralRe: Leading zero in hex formatting Pin
Luc Pattyn27-Jun-09 12:31
sitebuilderLuc Pattyn27-Jun-09 12:31 
GeneralRe: Leading zero in hex formatting Pin
Christian Graus27-Jun-09 12:38
protectorChristian Graus27-Jun-09 12:38 
GeneralRe: Leading zero in hex formatting Pin
Ed.Poore27-Jun-09 14:01
Ed.Poore27-Jun-09 14:01 
GeneralRe: Leading zero in hex formatting Pin
Luc Pattyn27-Jun-09 15:07
sitebuilderLuc Pattyn27-Jun-09 15:07 
GeneralRe: Leading zero in hex formatting Pin
Ed.Poore27-Jun-09 23:47
Ed.Poore27-Jun-09 23:47 
GeneralRe: Leading zero in hex formatting Pin
Trollslayer27-Jun-09 13:53
mentorTrollslayer27-Jun-09 13:53 
GeneralRe: Leading zero in hex formatting Pin
Ed.Poore27-Jun-09 14:00
Ed.Poore27-Jun-09 14:00 
GeneralRe: Leading zero in hex formatting Pin
Trollslayer27-Jun-09 14:13
mentorTrollslayer27-Jun-09 14:13 
JokeRe: Leading zero in hex formatting Pin
Christian Graus27-Jun-09 14:21
protectorChristian Graus27-Jun-09 14:21 
GeneralRe: Leading zero in hex formatting Pin
Luc Pattyn27-Jun-09 14:04
sitebuilderLuc Pattyn27-Jun-09 14:04 
AnswerRe: Leading zero in hex formatting Pin
Luc Pattyn27-Jun-09 12:10
sitebuilderLuc Pattyn27-Jun-09 12:10 

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.