|
Why don't you do a check to see if the file already exist? You need to work with File.Exist() method.
|
|
|
|
|
hi i have created stored procedure as follows:
ALTER PROCEDURE dbo.StoredProcedure1
(
@ID varchar(50),
@PassWord varchar(50),
@confirmPassword varchar(50),
@EmailID varchar(50)
)
AS
insert into Login(ID,Password,ConfirmPassword,EmailID)Values(@ID,@PassWord,@ConfirmPassWord,@EmailID)
RETURN
then i have used this storedprocedure in coding as.Actually m tryin to submit a form containing
id,password,conformpassword,email in table named Login:the code is:
public partial class emplogin : System.Web.UI.Page
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Jajaipur"].ConnectionString);
SqlCommand cmd=new SqlCommand();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlParameter ID = new SqlParameter();
SqlParameter Password = new SqlParameter();
SqlParameter Confirm = new SqlParameter();
SqlParameter Email = new SqlParameter();
cmd.Parameters.Add("@ID", SqlDbType.VarChar).Value=txtid.Text;
cmd.Parameters.Add("@Password", SqlDbType.VarChar).Value=txtpassword.Text;
cmd.Parameters.Add("@Confirm", SqlDbType.VarChar).Value=txtconfirmpassword.Text;
cmd.Parameters.Add("@Email", SqlDbType.VarChar).Value=txtemailid.Text;
cmd = new SqlCommand("StoredProcedure1",conn);
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
txtid.Text="";
txtpassword.Text="";
txtemailid.Text="";
txtconfirmpassword.Text="";
}
}
i got this error on rub time:Procedure or function 'StoredProcedure1' expects parameter '@ID', which was not supplied.
plz tell me wr m i wrong....
|
|
|
|
|
Ok.
Short version: move this line:
cmd = new SqlCommand("StoredProcedure1",conn);
to the top of your method.
Longer version: read up on collections.
[edit]sorry, wrong line[/edit]
mylogics wrote: i got this error on RUB time
I know it was a typo, but soooo funny
var question = (_2b || !(_2b));
|
|
|
|
|
i tried but givin same error...
|
|
|
|
|
Look man, it wont give an error, alright?
Please read my edited post.
You were adding to a collection of an object and then you constructed it again, therefore losing all previously assigned properties.
Move that line to before you're starting to add parameters and all will be well.
Believe me.
var question = (_2b || !(_2b));
|
|
|
|
|
thnks it worked...
|
|
|
|
|
change the code as blow....
protected void Button1_Click(object sender, EventArgs e) {
SqlCommand cmd = new SqlCommand("StoredProcedure1",conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@ID", SqlDbType.VarChar).Value=txtid.Text; cmd.Parameters.Add("@Password", SqlDbType.VarChar).Value=txtpassword.Text;
cmd.Parameters.Add("@Confirm", SqlDbType.VarChar).Value=txtconfirmpassword.Text;
cmd.Parameters.Add("@Email", SqlDbType.VarChar).Value=txtemailid.Text;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
txtid.Text="";
txtpassword.Text="";
txtemailid.Text="";
txtconfirmpassword.Text="";
}
|
|
|
|
|
To update the page Friend.aspx partially by clicking on button deleteFriend of usercontrol Profile.ascx I use following code
Friend.aspx
<%@ Register Src="~/UserControls/ProfileDisplaySmall.ascx" TagPrefix="Kooras" TagName="ProfileDisplaySmall" %>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<Kooras:ProfileDisplaySmall ShowConnectionRequestButton="false" ShowDeleteButton="false" ID="pdProfileDisplay" runat="server" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Label ID="Label4" runat="server" Text="Label"></asp:Label>
</ContentTemplate>
<Triggers>
</Triggers>
</asp:UpdatePanel>
But nothing to do
I also add
<Triggers>
<asp:AsyncPostBackTrigger ControlID="deleteFriend" EventName="click"/>
</Triggers>
Profile.ascx
<asp:ImageButton ImageAlign="AbsMiddle" ID="deleteFriend" CssClass="cross" runat="server" OnClick="ibDelete_Click" ImageUrl="~/images/cross_icon_normal.png" />
Now compiler says deleteFriend does not exist in the current context(at Friend.aspx ).
What can I do? Plz ...
shahdat
|
|
|
|
|
I just suppose that u don't need to add triggers section
<Triggers>
<asp:AsyncPostBackTrigger ControlID="deleteFriend" EventName="click"/>
<Triggers>
it will remove the error of "DeleteFriend does not exist in the current context". Then just put a breakpoint on profile.ascx.cs file at function ibDelete_Click so that you can identify that there is no error in actual code.
and if you are displaying some message in some control or refreshing content of any control after delete then make sure that that particular control is the child of same UpdatePanel in which u have placed the Profile User Control's instance.
I hope it gonna help u.
|
|
|
|
|
Hi,
I have bought hosting and I put there all my web project,in folder App_Data I have database which I have created in SQLExpress.
Problem is that I cant connect in databse which is in host,in localhost works good without problem.
My connection string in webconfig file is
<br />
<add name="DBConn" connectionString="Server=www.mydomainname.com;Database=myDatabaseName;Trusted_Connection=True;"<br />
providerName="System.Data.SqlClient" /><br />
</connectionStrings>
I get error
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
How can I make connection string to access in database.
|
|
|
|
|
fattycode wrote: Server=www.mydomainname.com
This should be the url. Check with your hosting provider regarding the Server name/ipaddress.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
www.mydomainname.com I used only to explain problem,that is not my real domain name.
I tried too most of connection strings from www.connectionstrings.com but still is not working
|
|
|
|
|
i think u have to provide the access credentials to the database in the connection string.
|
|
|
|
|
Can you give me any example or any link to read about it?
|
|
|
|
|
try this sample connection string
Data Source=yourdataserver;Initial Catalog=databasename;Persist Security Info=True;User ID=DBusername;Password=DBpassword
just replace the values from the actual value.
|
|
|
|
|
Try it by using the IP address, Database server User ID and password...
it will work
|
|
|
|
|
My database is inside App_Data folder and I used this connection string but again I cant access my database.
Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbname.mdf; Database=mydbname;Trusted_Connection=Yes;
|
|
|
|
|
I have a gridview in my form which populates data when loading the form. There is a dropdown on the top of the gridview which shows 'Results per page:' . It has values of 10, 25, 50 & 100, which is working fine. There is also an Export to Text functionality as well as there is an hyperlink in the gridview.
The issue is: when I change the number of results per page to 25, it displayes less than or equal to 25 records and when come back to page after export to test and then click on gridview hyperlink, the dropdownlist still shows 25, but records in gridview will be in three pages, 10 in each page.
Even though I added the code history.go(-1) in the new form when clicking on hyperlink in the gridview, it is not maintaing the history and shows incorrect results. This is happening only IN IE and not in Firefox. ANy idea how this is happening? Any fix for this? please help.
Thanks,
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
|
have u tried setting rows per page to 25 in the page_load.
|
|
|
|
|
Hi All,
I have a image button. I would like to call client side function as well as server side function in same button in same time.
remember I don't want to call any javascript confirmation.
Need yours advice....
|
|
|
|
|
vnsraj wrote: I would like to call client side function
vnsraj wrote: remember I don't want to call any javascript confirmation.
You just can't do it. You CAN call client side methods BEFORE calling the server, but, by definition, it has to be javascript. What else could it be ? Do you know what it is you're asking ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
vnsraj wrote: remember I don't want to call any javascript confirmation.
what you mean exactly?
Your question is not clear.
BTW use OnClientClick for adding client method and OnClick for server side code.
|
|
|
|
|
I have a image button, I want to called a server side function in image button onclick function on same time I want to called a javascript function.
|
|
|
|
|
Its possible to inject javascript snippets using ScriptManager.RegisterStartupScript .
Why you want 2 do that?Actually vat u r trying 2 achieve?
|
|
|
|