|
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
|
|
|
|
|
Here is the message that pops up when i try to run my code in C#
server error: in :application specified web pages version "3.0.0.0" could not be found. update your web.config to specify a different version. current version: "2.0.0.0:"
|
|
|
|
|
Probably a good idea to do what the message tells you.
|
|
|
|
|
I have tried that and it seems its leading me to more errors
|
|
|
|
|
There's a secret error somewhere in your secret code. You should fix that.
Seriously, how do you expect anyone to be able to help you based on the complete lack of information you've provided?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
So sorry for that
here is the thang: I cant take a pic of it
Server Error in '/' Application
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: The CodeDom provider type "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral. publicKey=31bf3856ad364e35" could not be located.
... to add to that.. the web.config and packages.config are ticked red
|
|
|
|
|
You either haven't installed the Microsoft.CodeDom.Providers.DotNetCompilerPlatform package, or the version you have installed doesn't match the version specified in your web.config file.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks Richard i have tried to install and now i am getting a different error gain.
Thanks for your help..this is the new error
Server Error in'/' Application
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error and modify your source file appropriately.
Parse Error Message: Could not load type 'NPA.MvcApplication'
|
|
|
|
|
You have an error in your Global.asax file - it doesn't match the Global.asax.cs class definition.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
thank you for your responses. HOW DO I GO ABOUT CORRECTING THE ERROR
|
|
|
|
|
Fix your code so that the class name matches.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you so much man...
now there is another error displaying after installing
Server Error in'/' Application
Parse Error Message: vould not load type 'NPA.MvcApplication'
|
|
|
|
|
In my opinion there's a strange error in the message you're receiving. It shouldn't say that because what is describing has nothing to do with running your code.
|
|
|
|
|
Dear folks.
I am writing a program for connecting sql server database, and populating data from table using a stored procedure. it is working fine when I use the app.config file's data source as the server name, but when I use the server's ip address and port, it is not working.
it is showing error, stored procedure not found.
My app config's connection string is as below.
<connectionStrings>
<clear />
<add name="CONNECTION_FLOR"
providerName="Microsoft.Data.SqlClient"
connectionString="Data Source=172.142.1.100,1433;User ID=redacted;Password=redacted;Initial Catalog=tempdb;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False" />
</connectionStrings>
But when I use Data Source by name as Data Source=(localdb)\SubdivprojV13; it is working all good. The problem is with ip address and port. I checked the connection, connection is opening. But showing error as stored procedure not found.
please check my code snippet.
Public Class Form1
Dim connection As New SqlConnection(ConfigurationManager.ConnectionStrings("CONNECTION_FLOR").ConnectionString)
Private Sub BTN_DISPLAY_Click(sender As Object, e As EventArgs) Handles BTN_DISPLAY.Click
Dim cmd As New SqlCommand With {
.Connection = connection,
.CommandType = CommandType.StoredProcedure,
.CommandText = "SP_DISPLAY"
}
cmd.Connection.Open()
lbl_CONN.Text = "Connected"
lbl_CONN.ForeColor = Color.Green
Dim dt As DataTable = New DataTable()
dt.Load(cmd.ExecuteReader)
DataGridView1.DataSource = dt
DataGridView1.Update()
If connection.State = ConnectionState.Open Then
connection.Close()
lbl_CONN.Text = "DisConnected"
lbl_CONN.ForeColor = Color.Red
End If
End Sub
End Class
Any help is highly appreciated. Thanks in advance,.
modified 12-Apr-21 12:09pm.
|
|
|
|
|
You are connecting to two different databases. One is a full SQL Server database; the other is a "LocalDB" database.
SQL Server Express LocalDB - SQL Server | Microsoft Docs[^]
LocalDB databases cannot be accessed across the network.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks for posting the username and password in your connection string.
You might want to change that account name and password now and don't ever use that account name ever again.
|
|
|
|
|
It's not even a private IP address!
Looks like the OP is using Verizon as their ISP. I wonder whether they've managed to open port 1433 up to the internet? :evilgrin:
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I'm really sorry not being able to give you a good solution for this problem you are describing. However, I recommend you going to the tech forum on Craiglist. You could find an answer over there.
|
|
|
|
|
using (SQLiteCommand cmd = conn.CreateCommand())
{
try
{
cmd.CommandText = @"SELECT * FROM. customer WHERE lastname = @setName";
cmd.Parameters.AddWithValue("@setName", txt_name.Text);
da_Customer = new SQLiteDataAdapter(cmd.CommandText, conn);
dt_Customer = new DataTable();
da_Customer.Fill(dt_Customer);
dgv_customer.DataSource = dt_Customer;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
I get insufficient parameters supplied with this block of code, any ideas why?
|
|
|
|
|
At what line? It says so in the exception, so why can't you?
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
First, clean up your code indentation. It makes debugging your code easier and reduces the number of bugs in your code.
Next, in your SQL statement, get rid of the period you have on the FROM clause. Then get rid of the * and replace it with the fields you want. Trust me, using "SELECT *" is NOT a habit you want to get into.
SELECT fieldList, ... FROM customer WHERE lastname=@setName";
After that, why are you creating a SqlCommand object only to throw it out and never use it with the DataAdapter? The SqlDataAdapter will take a SqlCommand object as a parameter, but you just pass in the SQL statement (.Text property) of the command you built, effectively ignoring the parameter object you built.
Your code should be this:
using (SQLiteCommand cmd = conn.CreateCommand())
{
try
{
cmd.CommandText = @"SELECT * FROM customer WHERE lastname = @setName";
cmd.Parameters.AddWithValue("@setName", txt_name.Text);
da_Customer = new SQLiteDataAdapter(cmd);
dt_Customer = new DataTable();
da_Customer.Fill(dt_Customer);
dgv_customer.DataSource = dt_Customer;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
} Also, it seems you're using class global data objects, "da_Customer", "dt_Customer", ... This is a REALLY BAD IDEA and will get you into trouble in the future with bugs that are really difficult to find.
You should have individual methods that will return data, creating and disposing their own database objects, more like this:
public DataTable GetCustomerTableFromLastName(string lastName)
{
using (SQLiteConnection conn = new SQLiteConnection(CONNECTIONSTRING))
{
SQLiteCommand comm = conn.CreateCommand();
cmd.CommandText = @"SELECT firstname, lastname, something, somethingElse FROM customer WHERE lastname = @setName";
cmd.Parameters.AddWithValue("@setName", txt_name.Text);
SQLiteDataAdapter adpat = new SQLiteDataAdapter(cmd);
DataTable tableResult = new DataTable();
adapt.Fill(tableResult);
return tableResult;
}
} But, even though this is an improvement, it still falls way short of production quality code.
modified 25-Mar-21 9:20am.
|
|
|
|
|
Adrian Rowlands wrote:
da_Customer = new SQLiteDataAdapter(cmd.CommandText, conn); Because you're passing the command text to the data adapter, not the command. The data adapter will create a new command using that command text, and none of the parameters you've added to cmd will be copied across.
Pass in the command object instead:
da_Customer = new SQLiteDataAdapter(cmd); But pay attention to Dave's advice (above[^]) as well.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
In my opinion, this could probably have a lot to do with the software you are currently using.
|
|
|
|
|