|
To use a variable in SQL you must declare it first, then you can use it.
e.g.
-- First declare the variable
DECLARE @myIntegerVariable int
-- Now it can be used.
SET @myIntegerVariable = 12;
-- To get the result of a column in a SELECT statement that returns just one row.
SELECT @myIntegerVariable = COUNT(*) FROM MyTable;
-- To use as a filter in a SELECT statement
SELECT * FROM MyTable WHERE MyColumn = @myIntergerVariable
If the variable is arriving as a parameter into a stored procedure, then the definition of the procedure declared the varibale implicitly. e.g.
CREATE PROCEDURE dbo.MyProc
@myFirstParameter int,
@mySecondParameter varchar(20)
AS
-- Do the processing of the Stored Procedure
GO
In C# you can supply varibles as parameters to any SQL in the SqlCommand.CommandText . This was the version that I showed you already in the example in my previous post.
Does this help?
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
OK! And I Understand .
thanks again !
mostafa hosseiny b.
|
|
|
|
|
I have an typed collection wich is bounded to datagrid control like this:
dataGrid1.DataSource = collection;
How to disable 'new row' in DataGrid ?
object oriented
uml oriented
iconix oriented
sql oriented
truespace oriented
---
solitare oriented 
|
|
|
|
|
airbus380 wrote:
How to disable 'new row' in DataGrid ?
Sorry if I missunderstood.
just do nothing in OnItemCreated event
<< >>
|
|
|
|
|
Check if your collection has a property called
AllowNew. Just set it to false.
|
|
|
|
|
I'm using MS Hierarchical FlexGrid to display hierarchical data from a database in a grid. As of now, I can't find out how to do that. I'm using Microsoft Visual C++ .NET 2003. I want to display data from two tables. One table has primary information, and the second table has multiple records for each record in the primary table. I'd like to display just the primary information and just let the user highlight a record to see what records in the second table belong to it. If anybody knows how to use the MSHFlexGrid (mshflxgrd.ocx... as opposed to the non-hierarchical one msflxgrd.ocx) and could offer any help, that'd be appreciated. Or if anybody knows how to solve this problem without mshflexgrid, that'd be great as well.
|
|
|
|
|
Lets see this can help
first filling records in grid
1.loop through the recordset
2.add a new blank row to the grid
3.keep a counter
4.use set_textmatrix(counter,colno) to fill records
now on click event of the datagird capture the row number that was clicked
use get_textmatrix to get the primary key value and show he data from the second table
|
|
|
|
|
Hi
I have a table as
mineralID year value
1 91 1000
2 91 2000
3 91 3000
1 92 500
2 92 300
3 92 8000
1 93 2000
2 93 1000
3 93 1100
I want to a table as
mineralID totalValue
1 3500
2 3300
3 12100
What should i do plz?
|
|
|
|
|
SELECT mineralID, SUM(value)
FROM MyTable
GROUP BY mineralID
The SUM() function tells the SQL Server to add together all the values in the value column, the GROUP BY tels SQL Server that rather than just a single total, you want a total for each mineralID .
Does this help?
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
If you want an upto date "table type" look at this data create a view
<br />
CREATE VIEW vw_Mineral_total<br />
AS<br />
SELECT mineralID, SUM(value)<br />
FROM MyTable<br />
GROUP BY mineralID<br />
If you want the Average
<br />
CREATE VIEW vw_Mineral_AVG<br />
AS<br />
SELECT mineralID, AVG(value)<br />
FROM MyTable<br />
GROUP BY mineralID<br />
|
|
|
|
|
Hi !
I have a variable (the following):
in Form1 we have:
....<br />
Public int myint;<br />
...<br />
private void btnOK_Click(object sender, System.EventArgs e)<br />
{<br />
....<br />
myint=4;<br />
...<br />
}
---
I Want to put this variable (myint) into the another variable (getmyint) in Form2.cs(formclass)
in form2 we have :
private void Form2_Load(object sender, System.EventArgs e)<br />
{<br />
....<br />
int getmyint;<br />
...<br />
} ---
How can I put the variable of form1(myint) into the variable in form2?
by the way, I made an object of the form1 in form2:
...<br />
Form1 getintform=new Form1();<br />
...<br />
private void Form2_Load(object sender, System.EventArgs e)<br />
{<br />
....<br />
int getmyint;<br />
getmyint=this.getintform.myint;<br />
...<br />
}
but I don't get any result , please guide me!
thanks!
mostafa hosseiny b.
-- modified at 3:39 Thursday 8th September, 2005
|
|
|
|
|
hi there,
because ur variable "myint" has not initialized yet in form1 constructor, so that's why u cannot get any result.
=> solution here:
1. should initialize the variable "myint" in form1 constructor
2. after creating form1 object in form2, just simply call it's btnOK_Click
Hope this helps
<< >>
|
|
|
|
|
can you help me please, how can write the initializing this variable "myint" in form1 ?
Yours !
mostafa hosseiny b.
-- modified at 7:55 Thursday 8th September, 2005
|
|
|
|
|
just simply assign ur variable in form1 constructor, somthing like this:
public form1()
{
myint = 4;
}
<< >>
|
|
|
|
|
thanks! but there is one difficult:
myint is in
btnOk_Click() Event and the value of this variable ,maby be vary ... ,
for example , everytime I run the application , the value of this variable maybe 1 OR 5 OR 8 and etc.
Yes , if we put a const value in the initializing for this , crtainly , we have no difficult but "myint" is in the btnOK_Ckick() Event.
guide me please!
thanks!
mostafa hosseiny b.
|
|
|
|
|
ok, in form2, just do followings:
form1 getintform1 = new form1();
getintform1.btnOK_Click(null,null) to assign ur variable
after that, u can get the value of ur variable.
<< >>
|
|
|
|
|
at the first , where I write the
getintform1.btnOK_Click(null,null);
In form_Load() or ...
and at the second ,how to assign my variable(myint in form1) to getmyint in form2?yours!
mostafa hosseiny b.
|
|
|
|
|
u call getintform1.btnOK_Click(null,null); after getintform1 is innitialized
after the function above is called, the variable myint is assigned the value
manije wrote:
how to assign my variable(myint in form1) to getmyint in form2?
just call: getmyint = getintform1.myint;
Hope this answers
<< >>
|
|
|
|
|
in form2 I wrote :
....
...
Form1 getintform=new Form1();
...
public Form2()
{
InitializeComponent();
getintform.btnOK_Click(null,null);
}
....
private void Form2_Load(object sender, System.EventArgs e)
{
....
int getmyint;
getmyint=getintform.myint;
....
}
Is it Right? Certainly No!Because I do'nt get any result?
Pleazzzz , help me!
mostafa hosseiny b.
|
|
|
|
|
how can i calculate the number of days in the current month in MS SQL Server 2000. can any body help me, no matter wether usage of Stored Proc, or any other code, i am sick of working on it.
FIRE
|
|
|
|
|
This will do it.
DECLARE @MonthInt int
DECLARE @YearInt int
DECLARE @TempVarChar varchar(30)
DECLARE @Mth_Start datetime
DECLARE @Mth_End datetime
DECLARE @DaysInMonth int
SET @MonthInt = 08
SET @YearInt = 2005
-- GET START NEXT MONTH START IN Char
Set @TempVarChar = '01/' + CAST(@MonthInt As Varchar(2) ) + '/' + CAST(@YearInt As Varchar(4) )
-- Convert to Date
Set @Mth_Start = (Convert( datetime, @TempVarChar, 103 ))
-- Go Back one day to get last day in Month.
Set @Mth_End = DATEADD( dd, -1, @Mth_Start)
-- Get total days in Month
SET @DaysInMonth = DATEPART(dd, @Mth_end)
SELECT @DaysInMonth
|
|
|
|
|
I'm trying to connect to Exchange 2003 and gain access to Appointment information. I have seen a few articles about doing this in webDev, or something like that, but know nothing about how it works. I am coding in C#. I tried Microsofts website, under their Exchange Developer section but couldnt't find any actual code camples. Is there a nice simple wasy way of connecting to Exchange and extracting information and I just haven't been able to find it, preferably using ADO.NET and by easy hopefully like connecting to a sql or OleDB connection.
--Peter
|
|
|
|
|
Hello
I've install MSDE and my soft don't run !
I think it's because anything listen at the port 1433
When i write "netstat -na" in the command window , any port 1433 !
How can i open this port ?
thank you
SeLoRBIS
|
|
|
|
|
hi there,
sorry if I misunderstood ur mean.
u mean that MSDE cannot run because the port 1433 is already occupied by another process, right?
SeLoRBIS wrote:
How can i open this port ?
if so, u cannot open this port because it's alredy openned.
so the only way in this case is that u need to find out which program/process is using this port. Then stop it and install MSDE
Gud luke
<< >>
|
|
|
|
|
The port 1433 is the port use by MSDE or MS SQL Server !
But he's not use by another application .
He's not use , that all .
And i want that MSDE use it!
When i write "netstat -na" in console windows I see he's not heard by anything !
He's Closed .
It's the reason , my application don't communicate with the database MSDE
Thank You !
SeLoRBIS
|
|
|
|