|
Here is a code project in asp.net.
i have to insert dynamically create rows in a table name : [Pin_Generate]
The number of rows are inserted by the user and then submit and it create that number of rows in that table.
But it cannot be done when its going 2nd time in a loop...
<br />
for (i = 1; i <= Convert.ToInt32(EnterByUserTextBox.Text); i++)<br />
{<br />
getNum();<br />
<br />
scomm1.Parameters.AddWithValue("@pid_no", lblprint_id.Text);<br />
scomm1.Parameters.AddWithValue("@pserial_no", lblserial_no.Text);<br />
scomm1.Parameters.AddWithValue("@ppassword", lblpassword.Text);<br />
<br />
sconn1.Open();<br />
int x = 0;<br />
x=scomm1.ExecuteNonQuery();
sconn1.Close();<br />
<br />
<br />
if (x > 0)<br />
{<br />
<br />
lblmsg.Text = "Successfully Created";<br />
update();<br />
<br />
}<br />
else<br />
{<br />
lblmsg.Text = "Please Try Again";<br />
}<br />
<br />
<br />
}<br />
Plz help me out.... its very urgent..
|
|
|
|
|
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))
{
}
using(SqlConnection sconn1 = new SqlConnection(connectionstring))
using(SqlCommand scomm1 = sconn1.CreateCommand())
{
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)
{
lblmsg.Text = "Please Try Again" + ex.ToString();
}
}
Best wishes,
Navaneeth
|
|
|
|
|
Good Answer Navaneeth...
Additionally I have also marked this as answer...
Cheers.
modified on Saturday, November 14, 2009 1:51 PM
|
|
|
|
|
Thanks friend.
Best wishes,
Navaneeth
|
|
|
|
|
hi gents,
In ASP.NET solution file is in Projects folder and project files are in Websites folder. I wanna to put both in the same folder in another location..
I have copied the files from projects folder to the websites folder and its working but when i move the files to some other location its giving error "One or more files cannot be loaded...."
Please help me to find a solution for this
Thanks in advance
Regards
Ahamed Azeem
software Programmer
|
|
|
|
|
Can you please elaborate your question.
Please don't forget to mark 'Good Answer', if you find it really a good one!
Kashif
|
|
|
|
|
Thanks a lot for your reply
I created a new website. The files are inside the visualstudio2005\projects\website1 and visualstudio2005\websites\website1
I have copied the files(.sln and .suo) in visualstudio2005\projects\website1\ to the visualstudio2005\websites\website1\ and then open the project. Its working fine.
But if i copy the website1 folder from visualstudio2005\websites\website1\ to c: drive.. i cannot open the project. It is saying one or more files cannot be loaded. If I put inside Websites folder in c drive then its working.. How can i solve this
The error showing is
One or more projects in the solution could not be loaded for the following reason(s):<br />
<br />
The project file or web has been moved, renamed or is not on your computer<br />
<br />
These projects will be labelled as unavailable in solution explorer, Expand the project node to show the reason the <br />
<br />
project could not be loaded.
Hope you understand
Thanks and Regards
Ahamed Azeem
software Programmer
|
|
|
|
|
Open the Solution(which eventually an XML file) in Notepad or any XML editor and modify with the relative path in the project section. For example :
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MyProject", "MyProject\MyProject.vbproj", "{4A2C4FC2-3D9B-4911-B5CC-3147EC7E8D6C}"
EndProject
Modify the section in bold. .NET IDE loads the project based on the project file path mentioned in project section. For multiple projects there should be more than one project block.
|
|
|
|
|
Plz help me if any one can.
How I can get Text From TypeAhead Control.
I am using Visual Studio and developing my project in Asp.net using c#.
like i am using
String str = TypeAhead1.Text;
but always null value is returned..
Simply on postback i want to show the selected text on label1. Plz send me code.
|
|
|
|
|
|
Ok.. But i think my message is overset.
|
|
|
|
|
Despite the cross posting and reposting and everything else. Did you try Google?
I thought to see what a typeahead control is and top of the search results comes this Code Project Article. Type-Ahead suggest textbox server control with Google AJAXSLT[^]
Your answer may be there, and if it is not I am sure the author can help you out if you post against that article.
Failing that there seems to be a load of other pages about the subject acording to Google.
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk
|
|
|
|
|
Sir,
In my ASP.NET application I have the dashboard.
Number of records needs to be fetched from database into it. Hence,I want to write stored procedure which gives me these records using multiple Select statements. Is it possible to fetch it? If yes how it can be done.
Thanx
|
|
|
|
|
Multiple select statements will return as a single datatset having more than one data tables.
For example, if the stored procedure is executing 3 select statements, the dataset returned will have three data tables. You can refer them as ds.Tables[0], ds.Tables[1], ds.Tables[3], and so on.
|
|
|
|
|
Thanx boss !!!
Its working with minor changes as
=ds.Tables[0].Rows[0][0].ToString();
Thanx a lot!
|
|
|
|
|
Hello,
i have created a web page that query an indexing server using the method search(string) existing in a class, and it is working fine.
i have created a web service that call this method in the same application and if i call the web service from the same application the funcion search return result but if i call the method from another application then no result found.
Note: i am using the same paremeter.
any idea.
regards,
dghdfghdfghdfghdgh
|
|
|
|
|
There must be some headers to the Web service that might be required when to call it. Must be the home application does this accurately while the application on another server doesnt. Or there might be some issues with configuration as well.
Did you build the Webservice ?
I dont know if there is some filter in Search function based on Client IP as well...
|
|
|
|
|
Hi!
I need to put two calendars on my page to get beginning and end date from the user. I have disable the autopostback property for both of them but when user change the selected date of one calendar selected date of the second calendar return to the default selected date automatically .Do you have any suggestion that how can I handle two calendar separately ?
Any advice would be really appreciated.
|
|
|
|
|
It's work fine, when i am using two calender Controls from Asp Controls..
are you want asp calender controls.
|
|
|
|
|
If it is a way to solution yes. I would only like to disable automatic update of my calendars.
|
|
|
|
|
Are you have placed the two calender controls on separate pages?
|
|
|
|
|
I noticed that When I changed the selected date JavaScript _doPostBack () method is automatically called How can I disable it without fully disable JavaScript on my page.
|
|
|
|
|
Dear Frnds...
i have one flash button thats in falsh file(*.swf), how to make a serevr Control.
for example i want to apply this code
MultiView1.SetActiveView(View1)
Can u help me any one..
|
|
|
|
|
|
Hai Aman
<object onclick="vb();" id="sha" runat="server"> haii
this is working...but m apply one class again but its not working
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
="" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="131" height="29" title="sha" data="Default.aspx" runat="server">
<param name="movie" value="btn_log.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#800000" />
<embed src="btn_log.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="131" height="29" bgcolor="#800000" />
|
|
|
|