|
The error could be at both, sorry that doesn't help does it.
If i do the (CONVERT(CHAR(10), dt_requested,103) as datetime) using the value 103 as the type which is the british datetime(what I want)then I get a convert error at the database level of
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
when running my select on the view. If i do it using the american standard which is 101...i think... then I get the error at the app level because my app is using expecting dates to be in the british format. That make sense? The problem comes with the way the DateTime is initially automatically stored in the database as this is stored in the british format as per my localisation settings.
I don't want to have to string format my dates whenever i use them so any help would be appreciated.
Cheers
Ian
|
|
|
|
|
Can anyone Please tell me what is the command to drop a particular column from a table OR alter a table.
Does it require that the table has no data while dropping a column ?
|
|
|
|
|
Try this:
ArchaBhandare wrote: Can anyone Please tell me what is the command to drop a particular column from a table.
ALTER TABLE tableName DROP COLUMN columnName.
ArchaBhandare wrote: Does it require that the table has no data while dropping a column ?
No, it can have data...
Regards,
Arun Kumar.A
|
|
|
|
|
Syntax to DROP a column:
ALTER TABLE table_name DROP COLUMN column_name
No,U can DROP the Column even if it contains data also.
Cheers
Chandu
|
|
|
|
|
Hi
I like to know the query for
Inserting values of COUNT(*) and SUM(column1) of TABLE_1 into TABLE_2
Please help me in this regard
Thank U
Chandu
|
|
|
|
|
Try this:
Begin
Declare @COUNT INT
Declare @SUM FLOAT
SELECT @COUNT=COUNT(*) FROM Table_1
SELECT @SUM=SUM(Column1) FROM Table_1
INSERT INTO TABLE_2 VALUES(@COUNT,@SUM)
END
Regards,
Arun Kumar.A
|
|
|
|
|
Its working
Thank u very much.
Cheers
Chandu
|
|
|
|
|
Insert into TABLE_2
Select Count(*), Sum(column1)
From TABLE_1
Wout Louwers
|
|
|
|
|
hi,
do you have an idee how can create a table with extern key?
please help
|
|
|
|
|
Hello i have to automate the process of instrument calibration system used at cement industry. Can any body help me in database design. i need acctually instruments specifications and their categories data .etc
waiting for reply
i m mustafvi from Pakistan
|
|
|
|
|
Hi
I am trying to populate Datagrid with result of stored procedure,but I am unable to do so.
I have to get the TOTAL COUNT of rows into the data grid.
My stored procedure is like this.....
usp_itemTotal --> Stored Procedure Name
CREATE PROC usp_itemTotal(@billNo INT)
BEGIN
AS
SELECT COUNT(*) FROM SuperMarketBill WHERE billNo = @billNo
I have to give the "billNo" at the time of executing the procedure.
and my C# code is som thing like this.....
cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "usp_itemTotal";
param = new SqlParameter("@billNo", SqlDbType.Int);
param.Value=101;
cmd.Parameters.Add(param);
da = new SqlDataAdapter(cmd);
da.Fill(ds);
dgCall.DataSource = ds;
dgCall.DataBind();
Please asssit me in this regard.
Thank u
Chandu
|
|
|
|
|
If you are just required to show the count then why do you require datagrid, you could simply assign to a control like label etc..
Check your datagrid too!What is the error?
Gautham
|
|
|
|
|
Thannk u.
Above this Data Grid I am diaplaying another Data Gird to Display all the records of the table and it is working fine.
To Match with that data grid I am using another Data Grid to display count.
I am just getting a blank Data Grid with no items.
Otherwise tell me how to insert a string value into a datagrid without binding the datagrid.
Thank U
Chandu
|
|
|
|
|
you have to write the code in the item databound event of the first datagrid, did you do that?
Gautham
|
|
|
|
|
No,I just call wrote all the functionality in Page Load event handler and it should be their for my logic.
-- modified at 3:48 Wednesday 16th May, 2007
Thank U
Chandu
|
|
|
|
|
Chandu,
The second datagrid where you want the count is in a datagrid so the logic for filling the second datagrid should be written in the itemdatabound event of the first datagrid.
If you do this way it would be fine!
Gautham
|
|
|
|
|
i try the following code:
public void RunOleDbTransaction(string myConnString)
{
OleDbConnection myConnection = new OleDbConnection(myConnString);
myConnection.Open();
OleDbCommand myCommand = myConnection.CreateCommand();
OleDbTransaction myTrans;
// Start a local transaction
myTrans = myConnection.BeginTransaction(IsolationLevel.ReadCommitted);
// Assign transaction object for a pending local transaction
myCommand.Connection = myConnection;
myCommand.Transaction = myTrans;
try
{
myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (100, 'Description')";
myCommand.ExecuteNonQuery();
myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (101, 'Description')";
myCommand.ExecuteNonQuery();
myTrans.Commit();
Console.WriteLine("Both records are written to database.");
}
catch(Exception e)
{
try
{
myTrans.Rollback();
}
catch (OleDbException ex)
{
if (myTrans.Connection != null)
{
Console.WriteLine("An exception of type " + ex.GetType() +
" was encountered while attempting to roll back the transaction.");
}
}
Console.WriteLine("An exception of type " + e.GetType() +
" was encountered while inserting the data.");
Console.WriteLine("Neither record was written to database.");
}
finally
{
myConnection.Close();
}
}
but i get the following exception : An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll
Additional information: This OleDbTransaction has completed; it is no longer usable.
this exception occure when : myTrans.Rollback();
Please help me avoid this exception.
Please advice.
|
|
|
|
|
Hi
Your code is working fine.
I commented all the catch Procedure and I executed your code.
It just giving the output and I also checked the table.Records are inserted.
Once check your catch block and execute it.
Cheers
Chandu
|
|
|
|
|
Thank you very muc h.
|
|
|
|
|
I need a store proc to convert text file to SQL2000 table using delimeter "|"
Rekha
|
|
|
|
|
awara wrote: I need a store proc to convert text file to SQL2000 table using delimeter "|"
Well congratulations on that. I need a donut - the difference is, somebody is just about to get me one.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Try the "BULK INSERT" SQL command with the "FIELDTERMINATOR" option.
|
|
|
|
|
1) Create the table.
2) Use the Bulk Insert sql statement. You can find the syntax and paramaters in BOL.
Jeff
|
|
|
|
|
Hi,
I was wondering if someone could point me in the right direction for the following problem:
I created a SQL database which includes a payment system to process customer payments, when defining the Table which will hold the Payments from customers, I couldn't decide if i should create a table for Payment Types (cash, credit card, checking etc...) and add a relationship for each customer payment to the Payment Type table, or use a set of predefined characters to identify payment types (S=cash, C=credit card, H=checking etc...)
A payment type table is definitely more in compliance with the relational database modal, but on the other hand, since i will at most only have 4 or 5 payment types it will offer much better performance since there is no joins and PK/FK constraints and it will save space as well.
|
|
|
|
|
Yet at you end up having a performance overhead when you end up having to convert the payment type back. Plus, what happens if you add a payment type? Add a row and get the functionality for free, or change a hunk of code to handle the new Quarterly Cash payment type that your customer wants?
Stick with the normalised version - the overhead of the fk isn't that great.
Deja View - the feeling that you've seen this post before.
|
|
|
|