Click here to Skip to main content
15,891,657 members
Home / Discussions / C#
   

C#

 
AnswerRe: nested string Pin
padmanabhan N28-Jun-09 18:59
padmanabhan N28-Jun-09 18:59 
AnswerRe: nested string Pin
Henry Minute28-Jun-09 22:56
Henry Minute28-Jun-09 22:56 
QuestionSystem.AccessViolationException: Attempted to read or write protected memory. Pin
Revathij28-Jun-09 0:29
Revathij28-Jun-09 0:29 
QuestionDeserialization Issue Pin
al3xutzu0027-Jun-09 23:28
al3xutzu0027-Jun-09 23:28 
AnswerRe: Deserialization Issue Pin
Giorgi Dalakishvili28-Jun-09 0:22
mentorGiorgi Dalakishvili28-Jun-09 0:22 
QuestionC# and TCP Pin
DannyAdler27-Jun-09 23:27
DannyAdler27-Jun-09 23:27 
QuestionDisallowing images in WebBrowser control Pin
SimpleData27-Jun-09 23:13
SimpleData27-Jun-09 23:13 
AnswerRe: Disallowing images in WebBrowser control Pin
dan!sh 28-Jun-09 0:33
professional dan!sh 28-Jun-09 0:33 
Questionkeystroke monitor Pin
Dushan12327-Jun-09 23:09
Dushan12327-Jun-09 23:09 
AnswerCROSS POST Pin
dan!sh 27-Jun-09 23:51
professional dan!sh 27-Jun-09 23:51 
AnswerKey-logger Pin
fly90428-Jun-09 0:10
fly90428-Jun-09 0:10 
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 

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.