 |
 |
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
Hi, I want to integrate outlook in my asp.net web application. I want to show <b>Outlook calendar</b> in my application. But I don't have any idea how to show. Please Help me.
|
|
|
|
 |
Hi Friends, plz help me with this error
My Error is :
An exception of type 'System.InvalidOperationException' occurred in System.Data.dll but was not handled in user code
Additional information: The given value of type String from the data source cannot be converted to type nchar of the specified target column.
String or binary data would be truncated.
My Code:
protected void Button1_Click(object sender, EventArgs e)
{
String strConnection = @"Data Source=MANOJ\SQLEXPRESS;Initial Catalog=MANOJ;Integrated Security=True";
string path = @"C:\Users\Manoj Kumar\Desktop\Update Folder\TESTING.xlsx";
//Create connection string to Excel work book
string excelConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=1\"";
//Create Connection to Excel work book
OleDbConnection excelConnection = new OleDbConnection(excelConnectionString);
OleDbCommand cmd = new OleDbCommand("select *from [Sheet1$]", excelConnection);
excelConnection.Open();
OleDbDataReader dReader;
dReader = cmd.ExecuteReader();
SqlBulkCopy sqlBulk = new SqlBulkCopy(strConnection);
//Give your Destination table name
sqlBulk.DestinationTableName = "TEST";
sqlBulk.WriteToServer(dReader); // Here i getting the above error
excelConnection.Close();
Response.Write("inserted");
}
----- Same code is running Fine when i working on VS 2010 and SQL 2005
Now i use VS 2013 and SQL 2012 Then i getting the error.
PLZ give me the error free code.
|
|
|
|
 |
One of the strings in your Excel sheet is longer than the column in your SQL database.
Unfortunately, the error message doesn't tell you which column is causing the problem. There's an open suggestion[^] asking Microsoft to fix it, but no sign of a fix yet.
You'll need to compare the length of the strings in your Excel sheet to the defined size of the columns in your SQL table. When you find the column(s) which are causing the problem, you'll either need to increase the column size in SQL, or truncate the string in Excel.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
 |
asp.net Sql server add GridView export excel but only information
|
|
|
|
|
 |
Do you have a question?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
 |
Hi
I'm having web application connect with sql dbase. When i read data from database and render it to textbox control i used HttpUtility.HtmlDecode to render it, but there is windows application and it also try to render to same value it render as "&" (exact value in database). how can i solve this issue, is there standard way to overcome this issue?
1 . Do i need decode in windows application as well?
2. Is it good to show encode value in web application text box (&)?
|
|
|
|
 |
I HTML encode HTML before I store it in a database column, and then decode if I need the HTML to be decoded.
It took me some years to figure it out after trial and error and various scenarios that came up.
Those ampersands for example in AT&T; can be quite annoying.
Maybe others do it different.
|
|
|
|
 |
1. Do I put my website in the same VS project as the Web API project, or a seperate one? It really isn't clear.
2. Is the authentication cookie based or token based?
Thanks
|
|
|
|
 |
1. It depends how you would publish your final product. If your API will be used as an 'private' group of functions by your site - you can put it in the same. However if this API will back different 'clients' (multiple sites) - separate them. (Notice that I wrote 'you can' - the reason is that I would separate them in any case for better maintenance...)
2. Authentication is token based, but that token need to passed between server and client and back. For that ASP.NET uses cookie if enabled, if not query string...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
 |
Thanks very much
|
|
|
|
 |
I need to open access file (accde) inside web browser in asp.net,what do I do?
|
|
|
|
 |
Is it a bad pratice to add a value to ViewBag and hide and show controls based on it's value? Example:
@if (ViewBag.Role == "Admin")
{
@Html.TextBoxFor(m => m.UserName)
@Html.ValidationMessageFor(m => m.UserName)
}
Also, if it is a good way to do things how would you use it to hide and show the parent View's partial views helper controls?
|
|
|
|
 |
As ViewBag is valid only for the current request, that means you have to reinitialize Role on every request. You better using session-wide storage (like TempData) for such info...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
 |
Thank you for your post. Would it not be better to have a USER Entity Framework table, which contains the the roles ID, and in the controller assign it to the modle value returned to the View like this:
@if(role.ID)
{
...
Now, this is how my boss wants to do it. Have the database that contain a USER table which has a role permissions enum value, then when the Controller looks up the user by AD value the role is checked and used to hide and show UI elements.The only questions I have are these: Along with the USER Entity model object for the Role we are passing back the RECORD Entity which contains data to fill Grids and text boxes to be bound to the View and all of it's partial Views. First, how do we pass back to the View both the ROLE the the RECORD entity data? Second if we use some kind of helper that contains the role can both the main View and it's Partial Views use the helper to hide and show the View controls?
|
|
|
|
 |
It sound me a bit over-made...
Search for 'role based authorization in mvc' in Google and you will learn that most of the things you try to develop here already exist...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
 |
Now, Im confused. Could you point me to an article explainning this?
|
|
|
|
|
 |
I am using the demo provided with the An Expandable .NET Gridview article. When I expand and contract the same row twice, the first time it works OK, but the second time all the content on the detail row is condensed on the first cell of the table. I'm looking at the source code and I have no idea where to look to find the source of this problem. Please help.
|
|
|
|
 |
Why not post the question to the author? Use comments section at the bottom of the article...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
 |
You are using a ASP.NET and ADO.NET to create an accounting application for your company.
You are writing code to run a set of stored procedures that perform posting operations in a
database at the end of each month. You use an OleDbConnection object to connect to the
database. You use an OleDbConnection object to connect to the database. You use an
OleDbCommand object to run the stored procedures. If an error occurs during execution of any
of the stored procedures, you want to roll back any data changes that were posted. You want the
changes to be committed only if all of the posting operations succeed. You write code to catch an
OleDbException object if an error occurs during the execution of a stored procedure. What else
should you do?
1. Call the Begin Trasaction method of the OleDbConnection object before running the stored
procedure. If an error occurs, use the OleDbConnection object to roll back the changes.
2. Call the BeginTransaction method of the OleDbConnection object before running the stored
procedures. If an error occurs, use the OleDbException object to roll back the changes.
3. Use the BeginTransaction method of the OleDbConnection object to create an
OleDbTransaction object. Assign the OleDbTransaction object to the Transaction property of
your OleDbCommand object. If an error occurs, use the OleDbTransaction object to roll back
the changes.
4. Use the BeginTransaction method of the OleDbConnection object to create an OleDbTransaction object. Pass a reference to the OleDbTransaction object to each stored procedure. Use error handling inside the stored procedures to roll back the changes
priya
|
|
|
|
 |
Problems with homework? Let do yourself a favor - at least try to do it alone!!!
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
 |
I m sorry.. But i couldn find out the correct answer......
|
|
|
|
 |
And you will not. Except your teacher posted it somewhere on the web...
The only way is to get together all you learned and try to create a solution. If you have a solution that doesn't work correctly (some error) you always can come back here an ask about that specific error, however you will not get an out-of-box solution here specially for home-work assignments...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
 |
Thank You...
I'll try to get it done and find solution for this...
|
|
|
|
 |
I want to know how to validate a textbox does not begin with the number 2
|
|
|
|
 |
Use a RegularExpressionValidator[^]:
<asp:RegularExpressionValidator runat="server"
ControlToValidate="TheTextBox"
ValidationExpression="[^2].*"
ErrorMessage="The text must not start with '2'."
/>
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
 |
thank you, It worked, please I'm looking for documentation on the regular Expression.
|
|
|
|
 |
Regular expressions are a very complex topic, but there are lots of resources to help:
This specific expression - [^2].* - means:
- any character other than '2' (
[^2] ),
- followed by zero or more repetitions (
* )
- of any character (
. ) at all.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
 |
Hi,
I have Create Dynamic Controls on dropdown SelectedIndexChanged event
protected void ddlcount_SelectedIndexChanged(object sender, EventArgs e)
{
Table tbldynamic = new Table();
for (int i = 1; i <= count; i++)
{
tr = new TableRow();
tc1 = new TableCell();
tc2 = new TableCell();
tc3 = new TableCell();
tc4 = new TableCell();
TextBox _txtQty = new TextBox();
_txtQty.ID = "txtQtyRow" + i;
_txtQty.Width = 50;
TextBox _txtRate = new TextBox();
_txtRate.ID = "txtRateRow" + i;
_txtRate.Width = 50;
TextBox _txtAmount = new TextBox();
_txtAmount.ID = "txtAmountRow" + i;
_txtAmount.Width = 50;
CheckBox _chkRowNo = new CheckBox();
_chkRowNo.ID = "chkRowNo" + i;
_chkRowNo.Text = i.ToString();
tc1.Controls.Add(_txtQty);
tc2.Controls.Add(_txtRate);
tc3.Controls.Add(_txtAmount);
tc4.Controls.Add(_chkRowNo);
tr.Cells.Add(tc4);
tr.Cells.Add(tc1);
tr.Cells.Add(tc2);
tr.Cells.Add(tc3);
tbldynamic.Rows.Add(tr);
}
}
I need to get values from dynamically generated Textbox on Button Click Event.
I am trying below,
protected void btnSave_Click(object sender, EventArgs e)
{
CheckBox chk = (CheckBox)Page.FindControl("MainContent").FindControl("MultiviewId").FindControl("view1").FindControl("Panel1").FindControl("chkRowNo1");
}
Here
MainContent = ContentPlaceHolderID,
MultiViewId = MultiView,
ViewId = view1,
PanelId = Panel1,
chkRowNo1 = Dynamically generated checkbox
I have also tried
CheckBox chk = (CheckBox)Page.FindControl("chkRowNo1");
CheckBox chk = (CheckBox)Panel1.FindControl("chkRowNo1");
But no use. It shows an object reference error. While debugging it shows null.
Some one could you help me...
|
|
|
|
 |
Hi
I want check box list combobox control in asp.net can any one help me?
Thanks
|
|
|
|
|
 |
Hello
I have three files in my simple 'Registration form' project - it inserts new user details into a MS Access database - comprising
an aspx, aspx.vb, and a Web.config file.
If I may post some of the code here, I was wondering if I can delete the following Sub Page_Load() from my aspx.vb file since I
can't see the purpose of it. In that aspx.vb file, I have:
Sub Page_Load()
Dim myMDBConnection As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("Register").ToString().Trim())
myMDBConnection.Open()
'do stuff here
myMDBConnection.Close()
End Sub
Protected Sub CreateUser_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim conn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=C:\myDatabase.mdb;")
Using conn
Dim Sql As String = "INSERT INTO userlist (username,password, strEmail) VALUES (@username,@password, @strEmail)"
Dim cmd As New OleDbCommand(Sql, conn)
conn.Open()
cmd.Parameters.AddWithValue("@username", username.Text)
cmd.Parameters.AddWithValue("@password", password.Text)
cmd.Parameters.AddWithValue("@strEmail", strEmail.Text)
cmd.ExecuteNonQuery()
conn.Close()
End Using
End Sub
End Class
And in my Web.config file I have:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="Register" providerName="Microsoft.Jet.OLEDB.4.0;"
connectionString="C:\myDatabase.mdb;" />
</connectionStrings>
</configuration>
Would it be 'safe' to remove that Sub Page_Load()?
Thank you for any advice.
|
|
|
|
 |
Look safe to me to delete, I don't see it really doing anything
|
|
|
|
 |
Thanks jkirkerx
Just removed it and all looks well!
Best regards
|
|
|
|
 |
Right On!
You only needs page events if your going to use them.
Just as a rule, I use Page.Load to load data
and Page.Init to load controls or HTML in code behind.
|
|
|
|
 |
So I could have used:
Protected Sub Page_Init(ByVal sender As Object, _
ByVal e As System.EventArgs)
username.Focus()
End Sub
|
|
|
|
 |
No,
you create things that you want to persist during the page lifecycle.
So if you need a textbox, you make it in Page.Init, so when you post back to the server, the textbox and it's value will live through the postback.
If you make the textbox in page.load, it will show, but the textbox will die during postback, causing the value to die as well.
Make Sense?
You use Page.Load to load data the first time the form is shown, and to make adjustments to the form elements for first time viewing.
|
|
|
|
|
 |
It's really important to learn the page lifecycle, before you get really fancy with your web apps. Otherwise you'll be posting many questions or headaches that don't make sense at that moment in time.
|
|
|
|
 |
Yes, I can imagine it will avoid headaches in the future.
There seems to be an abundance of articles here:
http://www.codeproject.com/search.aspx?q=life+cycle&x=7&y=6&sbo=kw[^]
so I have made a note to try to come to terms with the basic concepts over the next few days.
I am grateful that you have stressed it's importance. I suppose it's like learning any human language: we put basic building blocks - grammar, vocabulary, etc - in place to construct the skeleton of the language and only afterwards do we add flesh to it.
Thanks again, jkirkerx
|
|
|
|
 |
Hello:
i am using this kind of code for connection to the data base.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Configuration;
namespace Kiu_webS
{
public class Connections
{
SqlConnection _connection;
private string connStr = "";
public Connections()
{
connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
}
public Connections(string conStr)
{
this.connStr = conStr;
}
public string connectionString
{
get { return connStr; }
set { connStr = value; }
}
public SqlConnection GetDBConnection()
{
_connection = new SqlConnection(connStr);
return _connection;
}
public void connectDB()
{
try
{
_connection.Open();
}
catch
{
throw;
}
}
public void DisconnectDB()
{
try
{
_connection.Close();
}
catch
{
throw;
}
}
}
}
as i insert data from form to database i am getting this error. The coonection String property has not been initialized.
web.config file
<configuration>
<connectionStrings>
<add name="ConnStr" connectionString="Data Source = inayat; Initial Catalog = KIU; User ID=sa; Password=jan5562"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<authentication mode="Forms">
<forms name="KIUAuth" loginUrl="login.aspx" protection="All" path="KIUAuth/" timeout="30" slidingExpiration="true"/>
</authentication>
</system.web>
</configuration>
|
|
|
|
 |
public class Connections
{
SqlConnection _connection;
private string connStr = "";
public string connectionString
{
get { return connStr; }
set { connStr = value; }
}
public Connections()
{
connStr = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectinString"].ConnectionString;
}
public Connections(string conStr)
{
this.connStr = conStr;
}
public SqlConnection GetDBConnection()
{
_connection = new SqlConnection(connStr);
return _connection;
}
public void connectDB()
{
try
{
_connection.Open();
}
catch
{
throw;
}
}
public void DisconnectDB()
{
try
{
_connection.Close();
}
catch
{
throw;
}
}
}
In Web.config
<add name="ConnectinString" connectionString="Data Source=inayat;Initial Catalog=KIU; User ID=sa; Password=jan5562" providerName="System.Data.SqlClient" />
Works fine for me.
|
|
|
|
 |
I need to be able to figure out something very difficult. I have to create an MVC controller that will display the "User Profile" View (shows user information) when the "Display User Profile" View's ActionLink Is selected. Now, the user is an Active Directory user who has a user profile database entery created when loging into the application. The user profile data contains a profile data ID stored in Entity Framework. How would you recommend I access the user from the Entity Framework model? I know I should use the Entity Framework user profile ID when doing the controller search but don't know how to how to access it and how to find the user record for the actual search? Any help would be great.
Thanks,
Steve Holdorf
modified 4 days ago.
|
|
|
|
 |
I need to be able to figure out something very difficult. How do I create a parent Controller that dynamically hides and shows partial View's UI controls after the parent View's ActionLink controller is called? My example is I have a user roles model and based on the user's role when selecting the main View's ActionLink only certian UI controls are to be dynamically displayed in both the parent View and it's partial Views. Any help would be great.
Thanks,
Steve Holdorf
modified 4 days ago.
|
|
|
|
 |
A project gets built fine from Visual Studio without a problem from developers work station. Now we need to move it to DEV and UAT server. I've been struggling all day trying to get my ASP.NET project built with msbuild on a server with no Visual Studio installed (dev tools not permitted on servers) -
The type or namespace name 'Optimization' does not exist in the namespace 'System.Web'
The type or namespace name 'DotNetOpenAuth' could not be found
Couple attempts were made:
1. Install Windows SDK (http://msdn.microsoft.com/en-US/windows/hardware/hh852363) - appears there has been a lot of discussions from another Stackoverflow post (Couple relevant posts from Stackoverflow did not help[^]). You'd also need to add to environment variables PATH
C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools
(This did NOT help)
2: gacutil to install the dll's? (no vs command prompt - as said, no dev tool/Visual Studio permitted on server)
3: copy the dlls' to (i.e. same folder as MSBuild.exe):
C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\
(This did NOT help)
4: Copy local = true
(This did NOT help - the dll's apparent msbuild can't find already in bin folder of the ASP.NET application)
It appears to be a bug with msbuild - http://social.msdn.microsoft.com/Forums/vstudio/en-US/434abf1a-30db-4b13-8062-13755898dd71/msbuild-is-unable-to-link-to-a-webapplication-project?forum=msbuild
Anyone has experience with this? Thanks
dev
modified 5 days ago.
|
|
|
|
 |
I want to store the values of a Gridview selected row in sessions through a button field in the gridview but
its giving me a "Index out of range " error at
GridViewRow row = AdminSearchGridView.Rows[index]
Note: There is only one row in the gridview currently from which I want to select the values I want.
I checked that the e.CommandArgument is returning a int value 0 but
i cannot figure out what is going wrong since AdminSearchGridView.Rows[0] makes sense as there is a row in the gridview
then why Index out of range.?
Here is my code for Gridview...
<asp:GridView ID="AdminSearchGridView" runat="server" AutoGenerateColumns="False"
Style="color: #333333; border-collapse: collapse; font-size: 14px;
text-align: center;width: 1530px; margin-left: 0px; margin-top: 0px" CellPadding="4" ForeColor="#333333"
AutoGenerateDeleteButton="True" DataKeyNames="ID" OnRowDeleting="AdminSearchGridView_RowDeleting"
OnRowCommand="AdminSearchGridView_RowCommand">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:ButtonField ButtonType="Button" Text="Issue" CommandName="Issue" />
<asp:BoundField DataField="IssueStatus" HeaderText="Issue Status" />
<asp:BoundField DataField="AccessionNo" HeaderText="Accession Number" />
<asp:BoundField DataField="CallNo" HeaderText="Call Number" />
<asp:BoundField DataField="Title" HeaderText="Title" />
</Columns>
</asp:GridView>
Here is Code Behind...
protected void AdminSearchGridView_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Issue")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = AdminSearchGridView.Rows[index];
string accessno = AdminSearchGridView.Rows[index].Cells[3].Text;
string title = AdminSearchGridView.Rows[index].Cells[5].Text;
Session["accessno"] = accessno;
Session["title"] = title;
}
}
|
|
|
|
 |
The error suggests there are no rows in AdminSearchGridView at the time you call your code. Can you confirm it with debugger while running your code? The fact it is displayed on page doesn't mean it is available later
If it is the case then you can check the following:
- Make sure ViewState is enabled on your page.
- if you bind data to AdminSearchGridView in Page_Load() make sure it is no rebound on postback:
if (!IsPostBack) { }
--
"My software never has bugs. It just develops random features."
|
|
|
|
 |