I'm working on having two forms that communicate together. In order to do this, I am passing public value from the source page. Here's how I did it:
In the source page I have:
Public ReadOnly Property CurrentCity() As String Get Return txtboxfake.Text End Get End Property Then under page_load of the page I have: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load txtteam.Text = PreviousPage.CurrentCity txtboxdate.Text = Calendar1.SelectedDate End Sub
For some reason I keep getting an error that says "NullReference exception unhandled by user code" that points to txtteam.text = PreviousPage.CurrentCity.
I am doing the MVC Music Store on VS 2010 and I get this expection: System.Data.EntityException was unhandled by user code Message=The underlying provider failed on Open.
Source=System.Data.Entity
StackTrace:
at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) at System.Data.EntityClient.EntityConnection.Open() at System.Data.Objects.ObjectContext.EnsureConnection() at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source).....
It happens at the Album ablum line above. I checked and SQLExpress is running with login to Local system.
I'm stuck with this query. I've tried a lot but ended up with no clue. Here is my sql query which is worrying me.. sqlselect = "select qo.OrderDate,qo.RequiredDate,qo.ShippedDate" & _
I did executed a db - contact form page successfully in the same project with the same connection string, but for this page its doing error and so I commented the binary file saving codes and all and put just simple 2 fields to see if the db is connecting and surprisingly getting sqlexception error and no data is written to the db. I am using sqlexpress 2005 and VS 2008. After this code I am listing the error I got.
Imports System.Data.SqlClient Imports System.IO.FileInfo Imports System.Data Partial Class picture2 Inherits System.Web.UI.Page Protected Sub upButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles upButton.Click '' SOME CODES ARE HERE Dim ctr As Integer = 0 Dim fleName As String Dim fleLength As Integer fleName = FileUpload1.FileName fleLength = FileUpload1.PostedFile.ContentLength Dim fleDatasource As New SqlDataSource fleDatasource.ConnectionString = ConfigurationManager.ConnectionStrings("CandidatesConnectionString").ToString() fleDatasource.InsertCommandType = SqlDataSourceCommandType.Text fleDatasource.InsertCommand = "INSERT INTO Picture (picLength,picName) values (&picLength, &picName)" fleDatasource.InsertParameters.Add("picLength", fleLength) fleDatasource.InsertParameters.Add("picName", fleName) fleDatasource.Insert() ----------------------- executed and now the prg returns to my code with the following sqlexception error box and while expanded I got this info ------------------------ message - Incorrect syntax near "&" Line number 1 Errorcode -2146232060
in order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user. fleDatasource.Insert() the prg stops in the code with the green highlight on the fleDatasource.Insert().
I'm trying to do a master-detail by first search the database when a user click on the search button. Then display the result to a ListView control. After that, if the user click on the hyperlink, it displays the detail on the Formview control. Below are my code:
[Code]....
And here's the part that causes the error:
[Code]....
The error is on this line: string strID = ltvLusHmoob.DataKeyNames[e.Item.DataItemIndex].ToString();
I am making a login page in asp.net. when am trying to fill the data into the database it can give the error..."Incorrect syntax near 'Password'." my code is
i am getting this error, trying to connect to sqlserver! senario! im trying to connect 2 tables with corresponding information.
eg: table 1 has (item no., picture and link) table 2 has (all the information pertaining to the item number and picture meaning when you click on the link it has to link you back to the same picture with more information about it! what could possibly be wrong??
You can for example enter the length and width of the web (VS.NET2005), when it runs out of range index error exception was unhandled by user code for chieudai
I am createing user dynamially with the below code; string MyPassword = Membership.GeneratePassword(8,0).ToString(); Membership.CreateUser(TextBox7.Text, MyPassword, TextBox8.Text); but before I start creating, I would like to check if the user name is used before or not.
"System.FormatException was unhandled by user code - Input string was not in a correct format" This is driving me crazy! Can anyone see what the problem is?
i've got some problem reading excel files to store into sqlserver database. currently my code has a fileupload control and a button for me to save the excel file into a folder and read the data inside the excel file and write it into the sql database. The code works only if the excel sheet name is Sheet1.xlsx, however i tried upload a diff file named ImportUserFile.xlsx and it gave me the exception below. 'ImportUserFile$' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long. i have also tried other file names and it seemed only Sheet1.xlsx works.
I'm trying to throw the exception back to Page_Load but the throw statement causes error: ArgumentNullException was unhandled by user code. How can that be fixed? Also, I can't see Label1.Text displayed on the page after the ArgumentNullException occurs because the page is not re-load. If there is no exception, it's fine to not reload the page. How can I see the Label1.Text displayed?
I am a newbie and using Visual Web Developer 2008 Express Edition developing a website with some SQL database and a membership folder.
The membership folder security was set via Website/ASP.NET Configuration and with Permission Deny for Anonymous users, and a user id and password was created.
However when running the website and login with the created userid and password, it failed to log in with error message "Your login attempt was not successful. Please try again." I suspect that the system could not find the ASPNETDB.MDF even though it is in the App_Data folder.
I have separately developed another website with Membership and User Login by following the example in ASP.NET Walkthrough in Learn Web Devbelopment, and it works ok.
A question has been raised concerning password recovery revealing valid user ids. Stage 1 of the password recovery asks for a userid and when progressing to stage 2 will display an error message 'Invalid user id'. In theory this would allow valid user id'sto be identified.Is there a setting we are missing? Something that would allow the user id and question to be asked, then a message saying the 'User/Question combination is invalid'.
I have text box get data from dataread. Here my code:
OleDbCommand com = new OleDbCommand("select sid from TableOne where pid = " + "'" + PID.SelectedValue + "'" + " and gid = " + "'" + GID.SelectedValue + "'" + " and unitid = " + "'" + tid.SelectedValue + "'"); ........ ........ Txtsid.Text = myDataReader[0].ToString().Trim();
I got the run time error at line: Txtsid.Text = myDataReader[0].ToString().Trim(); Invalidoperationexception was unhandled by user code. No data exists for the row/column. How to try catching those errors?
I downloaded a sample Rolodex from here: [URL] the file to download is at the bottom of the page and it is called 'RolodexDatalist.zip (6.71 kb)' So I changed the HTML to it points to my SQL Server DB. I changed the ConnectionString to this:
Now, everything points to my DB! I thought, ok great, this should be pretty easy. However, when I debug, I get this error message: 'Null reference was unhandled by user code. Object reference not set to instance of an object. Troubleshooting Tips: use the "new" keyword to set an instance of an object.' This line is yellow:
Dim conStr As String = ConfigurationManager _ .ConnectionStrings("conStr").ConnectionString Here is the code-behind: Imports System.Data Imports System.Data.SqlClient Imports System.Collections.Generic Partial Class VB Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load If Not IsPostBack Then ViewState("CurrentAlphabet") = "ALL" Me.GenerateAlphabets() Me.BindDataList() End If End Sub Private Sub BindDataList() Dim conStr As String = ConfigurationManager _ .ConnectionStrings("conStr").ConnectionString Dim con As New SqlConnection(conStr) Dim cmd As New SqlCommand("spx_GetContacts") cmd.Connection = con cmd.CommandType = CommandType.StoredProcedure cmd.Parameters.AddWithValue("@Alphabet", ViewState("CurrentAlphabet")) con.Open() dlContacts.DataSource = cmd.ExecuteReader() dlContacts.DataBind() con.Close() If ViewState("CurrentAlphabet").ToString().Equals("ALL") Then lblView.Text = "all Contacts." Else lblView.Text = "Contacts whose name starts with " & _ ViewState("CurrentAlphabet").ToString() End If End Sub Private Sub GenerateAlphabets() Dim alphabets As New List(Of Alphabet)() Dim alphabet As New Alphabet() alphabet.Value = "ALL" alphabet.isNotSelected = Not alphabet.Value _ .Equals(ViewState("CurrentAlphabet")) alphabets.Add(alphabet) For i As Integer = 65 To 90 alphabet = New Alphabet() alphabet.Value = [Char].ConvertFromUtf32(i) alphabet.isNotSelected = Not alphabet.Value _ .Equals(ViewState("CurrentAlphabet")) alphabets.Add(alphabet) Next rptAlphabets.DataSource = alphabets rptAlphabets.DataBind() End Sub Protected Sub Alphabet_Click(ByVal sender As Object, ByVal e As EventArgs) Dim lnkAlphabet As LinkButton = DirectCast(sender, LinkButton) ViewState("CurrentAlphabet") = lnkAlphabet.Text Me.GenerateAlphabets() Me.BindDataList() End Sub End Class