|
Well, I guess that happens from time to time when I type directly into Code Project rather than conduct a test first. Which is a good thing to learn: Always test code before releasing it.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
Hi,
im not the best with SQL statements and have quite a tricky one to work out. If anyone could help me out id be extremely grateful.
I have a database of orders placed by customers, which need to be returned and counted in groups so for example the customer has ordered the following:
Car Tyre @ £50
Car Tyre @ £50
Car Door @ £25
Car Ariel @ £5
Car Tyre @ £50
So i need to return this information grouped as such:
3 * Car Tyre @ £150
1 * Car Door @ £25
1 * Car Ariel @ £5
it would also be useful to have a statement which gives me the same detail but with the price of a single item eg:
3 * Car Tyre @ £50
1 * Car Door @ £25
1 * Car Ariel @ £5
Thanks in advance!
munklefish
|
|
|
|
|
Try something like this:
SELECT COUNT(*) AS Quantity,
CarPart,
CarPartPrice,
SUM(CarPartPrice) AS CarPartTotalPrice
FROM Orders O
JOIN Customers C
ON C.CustomerID = O.CustomerID
WHERE C.CustomerID = 1
GROUP BY CarPart,
CarPartPrice
WITH ROLLUP
|
|
|
|
|
|
I learnt everything the hard way, using Notepad and IIS. I am used to SqlCommand, SqlDataReader, SqlConnection but I realized that these are no longer used in Visual Studio 2005.
Even when I type my code as below:
SqlCommand objCmd;
SqlDataReader objRdr;
void Page_Load(){
if(!IsPostBack){
BindData();
}
}
void BindData(){
objCmd = new SqlCommand("SELECT * FROM Warehouses", objConn);
objConn.Open();
objRdr = objCmd.ExecuteReader();
ddlWarehouses.DataSource = objRdr;
ddlWarehouses.DataValueField = "WarehouseID";
ddlWarehouses.DataTextField = "WarehouseName";
ddlWarehouses.DataBind();
objRdr.Close();
objRdr = objCmd.ExecuteReader();
lbWarehouses.DataSource = objRdr;
lbWarehouses.DataValueField = "WarehouseID";
lbWarehouses.DataTextField = "WarehouseName";
lbWarehouses.DataBind();
objRdr.Close();
objConn.Close();
}
The code above no longer work. Is there anyone that can teach me or give me a URL to where it teaches data binding of ADO.NET on Visual Studio 2005, along with how to Insert Update, Delete and Edit data to a database?
There are a lot of people who ended up doing things wrongly, even if they had the best of intentions at the beginning. Then again, there is no guarantee the words they said were conveyed as they originally were intended to be. That's because those on the receiving end only hear what they want to hear.
|
|
|
|
|
DataReader, command etc. are all still used in 2005. What is the error that you get?
|
|
|
|
|
I am using Visual Studio .NET 2003. I am getting a failed build of my solution that only contains one project called Unliquidated Obligations (It is a Report Project). No build errors are shown on the task list. I can right-click on any report, select build, and get the same error. I know there is nothing wrong with the reports themselves as they work fine in preview mode. For some reason it still says 1 failed at the bottom of the output as shown below. If I try and deploy the report, it will show the dialog box "There were build errors. Continue?".
Any help is appreciated.
------ Build started: Project: UnliquidatedObligations, Configuration: Debug ------
Build complete -- 0 errors, 0 warnings
---------------------- Done ----------------------
Build: 0 succeeded, 1 failed, 0 skipped
|
|
|
|
|
|
I downloaded and installed SQL 2005 Express so as i could use it in my Visual Studio... When i go to Add Item, and SQL Database, it is supposed to make a blank SQL DB which i can add my info into... When i click add i get the following message: An error has occurred while establishing a connection to the server. When connecting to the SQL Server 2005, This failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (Provider: SQL Network Interfaces, Error: 26 - Error Locating server/instance specified)
While this was true, i opened the settings for my connection and enabled remote connections and then restarted it. Yet the same error and problem still exist... Anyone with any more usful ideas on how i can get his up and running?
"Love, Life and Option Explicit"
|
|
|
|
|
I had similar issues with getting connection strings to work with VS2002 /VS2003 and VS2005 express with SQL server express 2005.
Solution: You need the machine and the instance name when speficifing a connection to the server MYPC\SQLSERVEREXPRESS
I also never got (local)\SQLSERVEREXPRESS to work.
I also had to setup a specific SQL user as well as windows authenication with SQL Express didn't work too well.
Hope this helps
|
|
|
|
|
Frank Kerrigan wrote: Solution: You need the machine and the instance name when speficifing a connection to the server MYPC\SQLSERVEREXPRESS
I also had to setup a specific SQL user as well as windows authenication with SQL Express didn't work too well.
Not really sure what you mean by setting up specific SQL users.. is that in SQL or do you mean another windows profile. im runnig XP HOME, which is why i had to use express as the full version is not compatable... might this be hindering it?
As for the server, i know the server name, and that doesnt seem to be helping. Any idea where i could find a nice trouble shooting guide perhaps? The SQL makes my head hurt. lol
"Love, Life and Option Explicit"
|
|
|
|
|
SQL accounts can be based on Windows accounts (or domain accounts) or SQL account that have no existence outside SQL.
Open SQL stidio manager and have a look at users.
|
|
|
|
|
I just tried to recreate your error and the closest I could get was when the SQLEXPRESS instance was not started.
Visual Studio and SQL are dead. Long live Visual Studio and SQL!
-- modified at 13:42 Monday 10th April, 2006
|
|
|
|
|
SQL express is very different to SQL Server. The following document should help to set it up.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvsdev05/html/vs05b1.asp
[^]
Also you could try connectionstrings.com
The good news is that if you do it all through code you can get it working just like a full version of SQL server and if you ever need to upgrade your Application to SQL server you just need to change the connection string.
Jon
|
|
|
|
|
Would perhaps my router for the network be affecting this? im just connecting to my own computer, but you never know with these things...
"Love, Life and Option Explicit"
|
|
|
|
|
hi,
when im using the follwing i'm getting a message that the command is already commited.
so how can i set up my odbc connection so that it will not auto commit all transaction.
OdbcCommand command = new OdbcCommand();<br />
OdbcTransaction transaction = null;<br />
<br />
command.Connection = connection;<br />
<br />
try<br />
{<br />
connection.Open();<br />
<br />
transaction = connection.BeginTransaction();<br />
<br />
command.Connection = connection;<br />
command.Transaction = transaction;<br />
<br />
command.CommandText =<br />
"Insert into Region (RegionID, RegionDescription) VALUES (100, 'Description')";<br />
command.ExecuteNonQuery();<br />
command.CommandText =<br />
"Insert into Region (RegionID, RegionDescription) VALUES (101, 'Description')";<br />
command.ExecuteNonQuery();<br />
<br />
}<br />
catch (Exception ex)<br />
{<br />
Console.WriteLine(ex.Message);<br />
try<br />
{<br />
<big>
transaction.Rollback();</big><br />
}<br />
catch<br />
{<br />
}<br />
}
please Help and thanks..
|
|
|
|
|
How to make a connection between ASP.NET Apllication and Tally Accounting software. and also how to import and export data from sql server to tally accounting software.
Pls give me suggestion and send some sample source code for the above.
Paul
|
|
|
|
|
i was not sure which forum to post this under but i hope someone can help me out. i am using microsoft visual basic express edition with sql server express edition. when the programs were first installed they worked fine, but recently i have been getting the error message: "Object reference is not set to an instance of an object", when i try to add anything to a sql database. i can create the database file but when i try to add a table or anything else to it i get that error. i tried uninstalling and reinstalling sql server express but it did not work. does anyone know how to fix this?
any help is greatly appreciated.
Thank you,
- Kyle
|
|
|
|
|
gr8coaster329 wrote: "Object reference is not set to an instance of an object",
You'll need to give us a snippet of code around the line where the exception occurrs. The error message means that something is set to null (or Nothing ) when it shouldn't.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
i did not enter any code for it. after adding the database to the project i tried to add a table to it by right clicking on tables under the database file in the database explorer window and selecting add new table and i get that error.
- Kyle
|
|
|
|
|
reinstalling visual basic express edition solved my problem.
thanks anyways for the help
- Kyle
|
|
|
|
|
Hello,
I'm a newbie using VB and SQL server Express editions. I have a windows forms application and a Web application that need to connect to the same database (Named WebCenter). But when I try to connect to it from the Web app while running the windows forms app this error message apears:
Unable to open the physical file "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\WebCenter_Data.MDF". Operating system error 32: "32(The process has no access to the file because is being used by another process).
Unable to open the physical file "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\WebCenter_Log.LDF". Operating system error 32: "32(The process has no access to the file because is being used by another process.)".
Cannot open database "WebCenter" requested by the login. The login failed.
Login failed for user 'CARLOS-PC\ASPNET'.
File activation failure. The physical file name "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\WebCenter_Log.LDF" may be incorrect.
Can anyone give me hand or point me in the right direction.
Thanks.
Pd. Please excuse my english.
Carlos.
|
|
|
|
|
Looks like your trying to open the db file directly rather than going through a ADO connection. You should be able to open almost unlimited connections to your SQL server.
Look at these for connection
http://www.codeproject.com/aspnet/SQLConnect.asp[^]
or search code project for "101 ADO"
Good luck and have fun
|
|
|
|
|
Hi Frank,
You were right. I was trying to open the same DB file twice. I had the DB attached to SQL Server Express from the Web application, but when I added the data source to my VB project the connection string tries to attach the DB file again. The only way around is to progamatically connect and retrive data from the DB without using VB Express Add New Data Source.. wizard.
Thanks for your help.
Carlos
|
|
|
|
|
How can I debug stored procedures under SQL-Server 2005. Setting breakpoint and so on....
Has anybody an idea?
Thank you!
|
|
|
|