|
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.
|
|
|
|
|
Message Removed
modified 21-Apr-21 16:03pm.
|
|
|
|
|
Message Removed
modified 21-Apr-21 16:03pm.
|
|
|
|
|
Hello.
I'm new in programming with asp.net core,
and would like to know how to Create an Invoice page?
What has already been created:
a) Model/Bill.class && Row.class
b) Pages/Bill/Create, Update, Delete pages
c) Pages/Rows/Create, Update, Delete pages
d) Data/InvoiceDbContext
e) startup database connection
I Would like to create a Bill and then add some rows to it.
How can i add rows to a bill?
Can somebody help me?
Thank you.
|
|
|
|
|
Member 14566520 wrote: I Would like to create a Bill and then add some rows to it. Add those rows in the database.
We don't know what your classes do, or don't. Assuming you read from a database as would be logical, and the classes load from there, then that's where you add new data.
Why did you start working on "what already been created", if this question is unanswered? How many manhours spent on those classes, whithout answering this one first?
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.
|
|
|
|
|
I have a question about using VS to build a VSTO solution for Excel:
I built an Excel template for the company I work for and a significant portion of it relies on macros (for example, one of the functions is to use the drawing tools to automatically draw a picture of the product being manufactured and calculate weight of material required, calculate angles, size of mold, etc., and another copies the folder structure with material take-off, fabrication instructions, etc., and renames it match the sales order). Every project we do is a custom project so I'm constantly finding new requirements that didn't exist at the time I originally built the template. Sometimes the new requirements expose an error in my programming that I wouldn't have found otherwise. When this happens I not only have to change the template, but all project files created with the template - we have on average 130+ active projects at any given time and each project could have 1 or more product profiles (the largest I've had is 204). Needless to say, a minor change becomes a major undertaking.
I'm thinking about maybe revamping the whole thing as a VSTO project in VS but I'm not sure if it's really the best answer. The template resides on a shared network folder so anyone who needs access to it can do so. If I build the project as an VSTO Excel document, will it retain the code necessary to perform the core functions after the file is saved? (It's not uncommon for customers to make a change to the initial design, or add new profiles midstream so the ability to continue editing after the initial save is essential.) Will users need to install anything locally? Same question if I go the Excel Addin route. Which option would be best suited to the need? If I go either route, will a change in the code promulgate to the documents using the template or addin or I am looking at an exercise in futility when it comes to updating/correcting code?
Any thoughts, insights, tales of joyous success or dismal failure are welcome.
Thanks.
|
|
|
|
|
Putting a business process entirely dependent on Office... Ewwww. As someone who has to deal with various Office plugins, this makes my skin crawl. Nobody, not one single vendor, creates and manages add-ins and extensions in a way that makes it easy.
But, an add-in is better than what you've got now. This is going to be an add-in to Excel. VSTO is not a project in itself, but it's the interface between your code and Office. Remember, it's an add-in to Excel, NOT YOUR TEMPLATE OR SAVED FILES. It's not saved in your Excel files!
This is something that every user that uses these sheets is going to have to install on their machines, and every time you update the code, they are going to have to uninstall the old version of the add-in and install the new one.
You're going to have to add repacking to your coding process to build the installer that's going to do the work of getting the add-in installed and registered. Oh, and one thing to make life easier. Install for machine, not the user.
|
|
|
|
|
Thanks Dave. Everything you said is what I feared about the endeavor I was undertaking. If I have to continually update every active file or go to every machine and uninstall/reinstall when I make a change to the code it doesn't seem worthwhile to go through the effort and extra overhead. My goal is to make things more efficient, not add a new layer of complexity. What I've been doing is making changes as I see it's necessary, updating my template, and worrying about updating existing project files on an as-needed basis. I think I can stick with that process for a while.
For the record, it's not a business process entirely dependent on Excel ("Live by the spreadsheet, die by the spreadsheeet"). It just automates a process that we were doing by hand so we can move projects out to the shop in under 5 minutes instead of an hour.
|
|
|
|
|
I used to make a living from people like yourself, power users who thoroughly understand their business processes and have put together a kludge solution that is not extensible.
I suggest you hire a developer who can interpret your business requirements and convert them into a database UI application. This does sound like a major job and because of the changing requirements it may be a long term rather than a short contract.
I suggest a relatively junior developer (not just a programmer) who has a passing knowledge of your industry. Then YOU will need to manage that process closely to insure a match to your requirements and future flexibility. Eventually you should end up as the primary user/support person with some occasional developer backup.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
I'm actually a certified professional programmer and have been developing VB/VBA solutions since VB 2....I just never delved into Excel addins so asking those who have done so seemed likea good place to start before working on a potential major change. Asking for insight from those who have gone before isn't necessarily a sign of someone who doesn't have a clue.
|
|
|
|
|
Some of us, including myself, start our development lives in VBA/VB/Excel/Access and that is why I assumed you were a power user. So I would recommend moving to c# (many more examples on the web than VB) and database (SQL Server) and moving the solution out of Office tools to a professional platform.
Using Office as anything but a productivity tool is always going to give you grief. I have only met 1 professional Excel developer in the last decade and I was not impressed his ideas were rigid and his tools were inflexible.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
"
Will users need to install anything locally? "
Yes. I've some experience creating and deploying VSTO's. These addins are installed manually. The few ones I made were Controls (visual components with graphics in it) and some Excel Basic function extensions. You can define a Basic function in a VSTO. The sheet - or template - contains the basic code calling the VSTO. Buttons can be defined, to let the Excel create a graphics control on the sheet that is defined in the VSTO.
It works for 365. But this is not without pitfalls. The validity of a VSTO depends on the Excel version installed. If you want to use VSTO, see you standardize your users on one version of excel, before trying to distribute your VSTO. Once your VSTO is installed, it can be replaced by a newer version if needed, by manually uninstalling it, leaving Excel, entering Excel again and install the new version of the VSTO.
So, bottom line: nstead of these 130 sheets, your will worry about all these PC's that need to install your addin. An addin is not like a template on a share. It is NOT updated automatically of you correct errors in your VSTO code ! So in short, I'm afraid VSTO is not the solution to your problem. If you really want dynamic code support, use scripts instead, like Powershell or C-script. You could use Excel interop to generate sheets..
Anyway in the end this will give a version maintenance mess. What would be a solution.. is making an inventory of what you trying to visualize in these sheets, devise a data model, implement a database for all data involved. Then export views from that database and (only) visualise using VSTO. From Excel, you can access the database directly and queries are stored in the templates. Your data should reside in a central place, not in 130 Excel sheets.
And yes alas.. this is an expensive project.
|
|
|
|
|
I am observing an issue with serializing/deserializing an object using CultureAwareComparer on .Net 4.6 .
On a system with .Net 4.6, I am able to serialize into a Soap XML having
<a2:CultureAwareComparer id="ref-15" xmlns:a2="http://schemas.microsoft.com/clr/ns/System">
<_compareInfo href="#ref-22"/>
<_ignoreCase>true</_ignoreCase>
<_options>IgnoreCase</_options>
</a2:CultureAwareComparer>
but when deserializing the same on a different system having .NET 4.6, I am seeing an error 'Member name 'System.CultureAwareComparer _options' not found.
Any suggestions on what could be causing the issue?
|
|
|
|
|
Did you first try de-serializing it on the same machine where it was serialized?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|