Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: Re: Date Parameter and stored procedure big problem


Message #1 by "dwarakanath hanumappanahalli" <madivi2002@y...> on Wed, 10 Apr 2002 18:18:55
It is better u use SQLDataTime as datatype instead System.DateTime.  I 
doubt if SQL Server supports System.DataTime. The namespace u have to use 
to get this datatype is System.Data.SQLTypes. Hope this helps u

-Dwarka


> Hi All

> There is a calender controller on my web page the value of that control 
is 
p> assed to Data layer using dataset object. In data layer I am extracting 
v> alue from dataset and creating dynamically parameter list for 
o> leDbCommand object to ececute a stored prcedure which is in Sql Server 
2> 000.
W> eb page code is 
d> tSetTab.Columns.Add("Address_id", System.Type.GetType("System.String"))
d> tSetTab.Columns.Add("Title", System.Type.GetType("System.String"))
d> tSetTab.Columns.Add("Contact_dt", System.Type.GetType
("System.DateTime"))

> Data Layer code is
 >  If Not dtSetTab.Tables().Columns(intCount).DataType Is   
 >                    System.Type.GetType("System.DateTime") Then
o> bjCommand.Parameters.Add(New System.Data.OleDb.OleDbParameter
(> dtSetTab.Tables0).Columns(intCount).ColumnName, OleDbType.VarChar, 
d> tset.Tables(0).Columns(intCount).MaxLength, 
S> ystem.Data.ParameterDirection.Input, True, CType(0, Byte), CType(0, 
B> yte), "", System.Data.DataRowVersion.Current, Nothing))
 >    Else
o> bjCommand.Parameters.Add(New System.Data.OleDb.OleDbParameter
(> dtSetTab.Tables(0).Columns(intCount).ColumnName, OleDbType.DBTimeStamp))
 >    End If

> Stored procedure is 

> CREATE PROCEDURE ams_i_contact 
 > @paddress_id int,
 > @ptitle varchar(10),
@> pcontact_dt datetime
A> S
B> EGIN
I> NSERT INTO contact(address_id,title ,
 > contact_dt, short_des,
 > next_conact_dt) VALUES (@paddress_id,@ptitle ,
@> pcontact_dt datetime)

> end

> This code is giving problem for Date field . It is creating data 
parameter 
i> n data layer but giving error while passing value from data layer to 
S> tored procedure

> Can anyone help me to sort out this problem 
A> ny kind of help will be appreciated 

> Thank You 
N> eeta Ambekar
 >        

  Return to Index