Click here to Skip to main content
15,888,286 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Read data from html file Pin
Satish - Developer14-Nov-09 18:39
Satish - Developer14-Nov-09 18:39 
GeneralRe: Read data from html file Pin
N a v a n e e t h14-Nov-09 20:24
N a v a n e e t h14-Nov-09 20:24 
AnswerRe: Read data from html file Pin
Abhishek Sur14-Nov-09 22:33
professionalAbhishek Sur14-Nov-09 22:33 
Questionquestion about image controle Pin
kimo code14-Nov-09 17:55
kimo code14-Nov-09 17:55 
AnswerRe: question about image controle Pin
Abhishek Sur14-Nov-09 22:35
professionalAbhishek Sur14-Nov-09 22:35 
GeneralRe: question about image controle Pin
kimo code15-Nov-09 7:16
kimo code15-Nov-09 7:16 
QuestionDynamic Insertion Pin
mca.mdebnath14-Nov-09 5:21
mca.mdebnath14-Nov-09 5:21 
AnswerRe: Dynamic Insertion Pin
N a v a n e e t h14-Nov-09 7:13
N a v a n e e t h14-Nov-09 7:13 
Welcome to CodeProject! Please read the forum guidelines[^] to learn how to ask better questions. People here do voluntary help and specifying urgent in the message won't help you to get answers. It is considered as rude.

To answer your question: what error are you getting? What getNum() function is doing?

There are few problems in your code. You are adding parameters in each iteration which is not correct. If you want to insert the same value N times, you don't have to open and close the database connection each time. Open it once, call ExecuteNonQuery() N times and close the connection. Here is the code after few refactorings.
int n;
if(!int.TryParse(EnterByUserTextBox.Text, out n))
{
    // Inform user about invalid input and return
}

// using block avoids resource leaks
using(SqlConnection sconn1 = new SqlConnection(connectionstring))
using(SqlCommand scomm1 = sconn1.CreateCommand())
{
     // Adding parameters
     scomm1.Parameters.AddWithValue("@pid_no", lblprint_id.Text);
     scomm1.Parameters.AddWithValue("@pserial_no", lblserial_no.Text);
     scomm1.Parameters.AddWithValue("@ppassword", lblpassword.Text);
     try
     {
         sconn1.Open();
         for (i = 1; i <= n; i++)
         {
              scomm1.ExecuteNonQuery();
         }
         sconn1.Close();
         lblmsg.Text = "Successfully Created";
         update();
     }
     catch(Exception ex)  // always catch specific exceptions than the base System.Exception
     {
         lblmsg.Text = "Please Try Again" + ex.ToString();
     }
}


Best wishes,
Navaneeth

GeneralRe: Dynamic Insertion [modified] Pin
Abhishek Sur14-Nov-09 7:43
professionalAbhishek Sur14-Nov-09 7:43 
GeneralRe: Dynamic Insertion Pin
N a v a n e e t h14-Nov-09 7:48
N a v a n e e t h14-Nov-09 7:48 
Questionissue in copying files from websites folder to some other location Pin
Ahamed Azeem14-Nov-09 2:26
Ahamed Azeem14-Nov-09 2:26 
AnswerRe: issue in copying files from websites folder to some other location Pin
Gamzun14-Nov-09 3:44
Gamzun14-Nov-09 3:44 
GeneralRe: issue in copying files from websites folder to some other location Pin
Ahamed Azeem14-Nov-09 4:28
Ahamed Azeem14-Nov-09 4:28 
GeneralRe: issue in copying files from websites folder to some other location Pin
Abhishek Sur14-Nov-09 7:55
professionalAbhishek Sur14-Nov-09 7:55 
QuestionTypeAhead Pin
sparlay_pk14-Nov-09 0:17
sparlay_pk14-Nov-09 0:17 
AnswerRe: TypeAhead Pin
saini arun14-Nov-09 0:30
saini arun14-Nov-09 0:30 
GeneralRe: TypeAhead Pin
sparlay_pk14-Nov-09 0:53
sparlay_pk14-Nov-09 0:53 
AnswerRe: TypeAhead Pin
The Man from U.N.C.L.E.14-Nov-09 3:06
The Man from U.N.C.L.E.14-Nov-09 3:06 
QuestionMultiple Select Statement in stored procedure Pin
deepseeindeepsy14-Nov-09 0:08
deepseeindeepsy14-Nov-09 0:08 
AnswerRe: Multiple Select Statement in stored procedure Pin
saini arun14-Nov-09 0:17
saini arun14-Nov-09 0:17 
GeneralRe: Multiple Select Statement in stored procedure Pin
deepseeindeepsy14-Nov-09 1:58
deepseeindeepsy14-Nov-09 1:58 
Questionindexing server Pin
ellllllllie13-Nov-09 23:35
ellllllllie13-Nov-09 23:35 
AnswerRe: indexing server Pin
Abhishek Sur14-Nov-09 7:59
professionalAbhishek Sur14-Nov-09 7:59 
QuestionHandle two calendar in an asp Page Pin
hande5413-Nov-09 23:23
hande5413-Nov-09 23:23 
AnswerRe: Handle two calendar in an asp Page Pin
sparlay_pk13-Nov-09 23:41
sparlay_pk13-Nov-09 23:41 

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.