|
1. With the statement below I was able to retrieved records using the @jv parameter.
declare @jv varchar(100)
set @jv = 'abh3'
SELECT jv,day, interval/4, sm, aiu, sum(att), ans,usg, acblk
FROM c204
WHERE [day] between '7-21-2003' and '7-22-2003'
and jv = COALESCE(@jv,jv)
GROUP BY jv,day,interval/4,sm,aiu,ans,usg,acblk
ORDER BY jv,day,interval/4,sm,aiu,ans,usg,acblk
GO
2. What is the solution if you have two value in one parameter like the example below, Does anyone know the answer. Please HELP I'm using it in my stored procdure.
declare @jv varchar(100)
set @jv = 'abh3','hal3'
SELECT jv,day, interval/4, sm, aiu, sum(att), ans,usg, acblk
FROM c204
WHERE [day] between '7-21-2003' and '7-22-2003'
and jv = COALESCE(@jv,jv)
GROUP BY jv,day,interval/4,sm,aiu,ans,usg,acblk
ORDER BY jv,day,interval/4,sm,aiu,ans,usg,acblk
GO
Dabuskol
|
|
|
|
|
dabuskol wrote:
set @jv = 'abh3','hal3'
Not quite sure what you are doing here. SQL Server does not support arrays so it does not seem possible you will have two values in one parameter. You can break them up manually and then build the query and execute it dynamically.
Rocky Moore <><
|
|
|
|
|
Hi There
Looks like you will have to revert to Dynamic sql. Build up the statement as required and then excecute.
This is normally a bit slower than straight sql but should be able to do the trick.
Regards
Peet Schultz
USE [PUBS]
DECLARE @LAST_NAME NVARCHAR(100)
DECLARE @SQL NVARCHAR(1000)
SET @LAST_NAME = '(''White'',''Green'')'
SET @SQL = 'SELECT * FROM AUTHORS WHERE [AU_LNAME] IN' + @LAST_NAME
EXEC (@SQL)
|
|
|
|
|
Thank you for your help. my stored procedure is working fine and so far the speed of retrieving doesn't affect much. Hope to hear from you guys in the future...
Good Luck
dabuskol
|
|
|
|
|
|
|
i want to make an oledbCommand with a variable as in sql @variable..SELECT *Table From Table WHERE Column=(thatvariable),how can i declare this to use in my code, am using Microsoft Access
|
|
|
|
|
|
thx neda for replying .. lol it was a good reply so .. my question was about how to declare an oledb parameter as in SELECT *Table From Table WHERE Column=(parameter),as declared in sql we use "@" b4 the parameter i was just asking wat i ll declare in ole instead of that "@".
|
|
|
|
|
Please go easy on me -I am New.
I created a SqlCommand and create a text update query such as:
update part set weight = '1' where part_id = 'test part'
I then created a button on my form and applied the following code:
Private Sub Button_load_it_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_load_it.Click
Me.SqlConnection1.Open()
Me.SqlCommand1.ExecuteNonQuery()
Me.SqlConnection1.Close()
End Sub
this works fine.
I now want to use a parameter for my weight input instead of the value '1' as in my query. The parameter will be supplied from a textbox on my form.
I cant seem to grasp the idea and nobody seems to be able to help me. I have read various books but none seem to describe the simple thing I am trying to accomplish.
Thanks , chris
|
|
|
|
|
Show your new SQL Command string after you modified it for using parameter.
|
|
|
|
|
Something like this?
<br />
SqlCommand cmd = new SqlCommand("SELECT some_column FROM some_table WHERE another_column = @some_value");<br />
cmd.Parameters.Add("@some_value", your_parameter);<br />
cmd.ExecuteNonQuery();<br />
(You put in your parameter in the second line...)
|
|
|
|
|
My parameter is coming from a textbox as its input. Is the "your_parameter" where i refererence the textbox?
|
|
|
|
|
This is what I tried to add and it caused and exception
Me.SqlCommand1.Parameters.Add("@WEIGHT", SqlDbType.Decimal)
Me.SqlCommand1.Parameters("@WEIGHT").Value = Me.TextBox_SBR_Runtime.Text
Me.SqlConnection1.Open()
Me.SqlCommand1.ExecuteNonQuery()
Me.SqlConnection1.Close()
The exception occured on this line:
Me.SqlCommand1.ExecuteNonQuery()
|
|
|
|
|
Hi all,
I would like to know how to create a inheritance relationship in Ms Access 2000.
I want to create a database for the product in a bookstore. But they have 2 types of products: Normal and consignment.
Each of the products will have a product ID. Since i need to have another relationship to the "invoice" table, I need to create this inheritance so that the invoice table can "connect" to all products.
e.g.
Normal Table:
*Prod_id
title...etc.
Consignment Table:
*Prod_id
title....etc.
Parent Table for product:
*Prod_id
Invoice Table:
*Invoice_id
*Prod_id
Qty...etc.
I cannot merge two products into a table because they carry different information.
Does anyone know????? thank!!!!
Note: Normal product and consignment product cannot be the same product, so the design that the "invoice" table carries the Normal_Prod_id and Consign_Prod_id DO NOT work in this case....i don't want to waste database space.
|
|
|
|
|
ChiYung wrote:
I cannot merge two products into a table because they carry different information.
I don't buy that at all... If this is a book store then most certainly thier products will have some attributes that are the same. They are all books and thus have attributes that are the same.
The rule is that all consignments are products, but not all products are consignment.
Create a general table that will hold ALL the common data about each 'product' (title, ISBN, etc...) then create secondary tables for those attributes that specificaly make them a 'Normal'or 'Consignment' type product. It might just be simpler, depending upon how many attributes that make them different, to just keep it all in one table and populate fields as needed, leaving some null wheer they don't apply.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
Thanks for your suggestion! I will see if it works in my case. (coz the item in this bookstore includes many things such as gifts, cards....etc.)
But I would like to know how to create such a "inherit" table in Access, so that I can create it by my own in the future. (for other cases)
Thanks a lot!!!!!!
|
|
|
|
|
ChiYung wrote:
(coz the item in this bookstore includes many things such as gifts, cards....etc.)
Oh, that makes a bit more sense then... I thought that they were all books.
Create one table that only contains a listing of the productID, and productType (normal; consignment; etc...) and maybe even a text description, then create secondary tables that use the productID as a foreign key to provide the extra data.
This really goes back to the first idea that I had though with keeping everything that is relivent to all products (and no matter WHAT it is that you seel, there will be relivent similarities between them all) in one table.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
Thanks for your reply.
But i still have questions. I think i need to give you more information of my current problem.
HERE IS MY ORIGINAL DATABASE DESIGN:
For normal product, i have to store these attributes:
<code>- Prod_id
- Prod_title
- Prod_ISBN
- Prod_publisher
- Prod_cost
- Prod_retailprice
- Prod_description
- Category_id
- Prod_max (Max On Hand)
- Prod_min (Min On Hand)
- Shelf_id
- Status_id</code>
For consignment product, i have to store these attributes:
<code>- Cons_Prod_id
- Cons_Prod_description
- Cons_cost
- Cons_retailprice
- Cons_member_id [FK] (for the table that stores the info of the person who consign this item)</code>
For Invoice, i have:
<code>- Invoice_number
- Prod_id [FK]
- Cons_Prod_id [FK]
- Qty</code>
I think in the invoice table, it's not making sense to have both Prod_id and Cons_Prod_id in the table. Because if a product has Prod_id, it won't have Cons_Prod_id or vice versa. In this case, there will be wasting memory space.
So I decided to modify it and use inherit relationship in order to use ONE Prod_id ONLY in the invoice table.
However, if i use your suggestion, it just solves the problem on how to distinguish the normal and consignment product.
I still need a table to store those extra information such as Cons_member_id because some information won't exist in both products. (e.g. Consignment table does not need Prod_max and Prod_min, but need cons_member_id)
Then i stuck here now...
I very appreciate your help to solve my problem!!
Thanks alot!!!!!
|
|
|
|
|
tblProducts
<code>
-ProdID [PK]
-ProdDescription
-ProdType [FK]
-Cost
-RetailPrice
</code>
tblProdNormal
<code>
-ProdID [FK]
-Title
-ISBN
-Publisher
-CategoryID
-Max (Max On Hand)
-Min (Min On Hand)
-ShelfID
-StatusID
</code>
tblProdCons
<code>
-ProdID
-MemberID [FK] (for the table that stores the info of the person who consign this item)
</code>
This does pretty good at getting things down to common stuff.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
how can i edit,save and delete data in a datagrid which datasource is a datable in a dataset,whick will make it look like microsoft access
|
|
|
|
|
hi,
Please try this website this will help you.. www.asp.net then goto tutotials then go to webcontrols then datagrids. Everything bout datagrid is there....
Dabuskol
|
|
|
|
|
thx i ve found the solution,just to put the endcurrentedit and update for the dataset code in the (CurrentCellChanged) Event of the DataGrid.. am using a windows application dunno if it is the same as Asp.net or not
|
|
|
|
|
I have 16Million records using SQL Server 2000. I'm retriving it using stored procedure in which the dates "from" and "to" is my criteria, at the same time I group all the records. Is this the best way??? please give advice.......
My stored procedure is working although i'm not satisfied with the result time. form 700,000 records it took me 1 min and 38 seconds....
|
|
|
|
|
Check indexes on the db table you are selecting from. Are there any index on dates column?
Tomas Rampas
------------------------------
gedas CR s.r.o.
System analyst, MCP
TGM 840,
293 01 Mlada Boleslav,
Czech Republic
Telefon/phone +420(326)711411
Telefax/fax +420(326)711420
rampas@gedas.cz
http://www.gedas.com/
------------------------------
To be or not to be is true...
George Bool
|
|
|
|
|