Click here to Skip to main content
15,897,718 members
Articles / Database Development / SQL Server

Nullable datetime column in .NET DataGrid with DateTimePicker

Rate me:
Please Sign up or sign in to vote.
5.00/5 (14 votes)
17 Aug 2009CPOL2 min read 148.6K   12.4K   48  
A nullable datetime column in .NET DataGrid with DateTimePicker.
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="NullDataDataSet" targetNamespace="http://tempuri.org/NullDataDataSet.xsd" xmlns:mstns="http://tempuri.org/NullDataDataSet.xsd" xmlns="http://tempuri.org/NullDataDataSet.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop" attributeFormDefault="qualified" elementFormDefault="qualified">
  <xs:annotation>
    <xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource">
      <DataSource DefaultConnectionIndex="0" FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout, AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
        <Connections>
          <Connection AppSettingsObjectName="Settings" AppSettingsPropertyName="NullDataConnectionString" ConnectionStringObject="" IsAppSettingsProperty="true" Modifier="Assembly" Name="NullDataConnectionString (Settings)" ParameterPrefix="@" PropertyReference="ApplicationSettings.NullDate.Properties.Settings.GlobalReference.Default.NullDataConnectionString" Provider="System.Data.SqlClient" />
        </Connections>
        <Tables>
          <TableAdapter BaseClass="System.ComponentModel.Component" DataAccessorModifier="AutoLayout, AnsiClass, Class, Public" DataAccessorName="tbl_DemoTableAdapter" GeneratorDataComponentClassName="tbl_DemoTableAdapter" Name="tbl_Demo" UserDataComponentName="tbl_DemoTableAdapter">
            <MainSource>
              <DbSource ConnectionRef="NullDataConnectionString (Settings)" DbObjectName="dbo.tbl_Demo" DbObjectType="Table" FillMethodModifier="Public" FillMethodName="Fill" GenerateMethods="Both" GenerateShortCommands="true" GeneratorGetMethodName="GetData" GeneratorSourceName="Fill" GetMethodModifier="Public" GetMethodName="GetData" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="true" UserGetMethodName="GetData" UserSourceName="Fill">
                <DeleteCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="false">
                    <CommandText>DELETE FROM [tbl_Demo] WHERE (([Id] = @Original_Id) AND ((@IsNull_Name = 1 AND [Name] IS NULL) OR ([Name] = @Original_Name)) AND ((@IsNull_Arrived = 1 AND [Arrived] IS NULL) OR ([Arrived] = @Original_Arrived)))</CommandText>
                    <Parameters>
                      <Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_Id" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Id" SourceColumnNullMapping="false" SourceVersion="Original" />
                      <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@IsNull_Name" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Name" SourceColumnNullMapping="true" SourceVersion="Original" />
                      <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="StringFixedLength" Direction="Input" ParameterName="@Original_Name" Precision="0" ProviderType="NChar" Scale="0" Size="0" SourceColumn="Name" SourceColumnNullMapping="false" SourceVersion="Original" />
                      <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@IsNull_Arrived" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Arrived" SourceColumnNullMapping="true" SourceVersion="Original" />
                      <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="DateTime" Direction="Input" ParameterName="@Original_Arrived" Precision="0" ProviderType="DateTime" Scale="0" Size="0" SourceColumn="Arrived" SourceColumnNullMapping="false" SourceVersion="Original" />
                    </Parameters>
                  </DbCommand>
                </DeleteCommand>
                <InsertCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="false">
                    <CommandText>INSERT INTO [tbl_Demo] ([Name], [Arrived]) VALUES (@Name, @Arrived);
SELECT Id, Name, Arrived FROM tbl_Demo WHERE (Id = SCOPE_IDENTITY())</CommandText>
                    <Parameters>
                      <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="StringFixedLength" Direction="Input" ParameterName="@Name" Precision="0" ProviderType="NChar" Scale="0" Size="0" SourceColumn="Name" SourceColumnNullMapping="false" SourceVersion="Current" />
                      <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="DateTime" Direction="Input" ParameterName="@Arrived" Precision="0" ProviderType="DateTime" Scale="0" Size="0" SourceColumn="Arrived" SourceColumnNullMapping="false" SourceVersion="Current" />
                    </Parameters>
                  </DbCommand>
                </InsertCommand>
                <SelectCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="true">
                    <CommandText>SELECT        Id, Name, Arrived
FROM            tbl_Demo</CommandText>
                    <Parameters />
                  </DbCommand>
                </SelectCommand>
                <UpdateCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="false">
                    <CommandText>UPDATE [tbl_Demo] SET [Name] = @Name, [Arrived] = @Arrived WHERE (([Id] = @Original_Id) AND ((@IsNull_Name = 1 AND [Name] IS NULL) OR ([Name] = @Original_Name)) AND ((@IsNull_Arrived = 1 AND [Arrived] IS NULL) OR ([Arrived] = @Original_Arrived)));
SELECT Id, Name, Arrived FROM tbl_Demo WHERE (Id = @Id)</CommandText>
                    <Parameters>
                      <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="StringFixedLength" Direction="Input" ParameterName="@Name" Precision="0" ProviderType="NChar" Scale="0" Size="0" SourceColumn="Name" SourceColumnNullMapping="false" SourceVersion="Current" />
                      <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="DateTime" Direction="Input" ParameterName="@Arrived" Precision="0" ProviderType="DateTime" Scale="0" Size="0" SourceColumn="Arrived" SourceColumnNullMapping="false" SourceVersion="Current" />
                      <Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_Id" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Id" SourceColumnNullMapping="false" SourceVersion="Original" />
                      <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@IsNull_Name" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Name" SourceColumnNullMapping="true" SourceVersion="Original" />
                      <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="StringFixedLength" Direction="Input" ParameterName="@Original_Name" Precision="0" ProviderType="NChar" Scale="0" Size="0" SourceColumn="Name" SourceColumnNullMapping="false" SourceVersion="Original" />
                      <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@IsNull_Arrived" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Arrived" SourceColumnNullMapping="true" SourceVersion="Original" />
                      <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="DateTime" Direction="Input" ParameterName="@Original_Arrived" Precision="0" ProviderType="DateTime" Scale="0" Size="0" SourceColumn="Arrived" SourceColumnNullMapping="false" SourceVersion="Original" />
                      <Parameter AllowDbNull="false" AutogeneratedName="Id" ColumnName="Id" DataSourceName="[C:\NULLDATE\NULLDATE\NULLDATA.MDF].dbo.tbl_Demo" DataTypeServer="int" DbType="Int32" Direction="Input" ParameterName="@Id" Precision="0" ProviderType="Int" Scale="0" Size="4" SourceColumn="Id" SourceColumnNullMapping="false" SourceVersion="Current" />
                    </Parameters>
                  </DbCommand>
                </UpdateCommand>
              </DbSource>
            </MainSource>
            <Mappings>
              <Mapping SourceColumn="Id" DataSetColumn="Id" />
              <Mapping SourceColumn="Name" DataSetColumn="Name" />
              <Mapping SourceColumn="Arrived" DataSetColumn="Arrived" />
            </Mappings>
            <Sources />
          </TableAdapter>
        </Tables>
        <Sources />
      </DataSource>
    </xs:appinfo>
  </xs:annotation>
  <xs:element name="NullDataDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msprop:Generator_UserDSName="NullDataDataSet" msprop:Generator_DataSetName="NullDataDataSet" msprop:EnableTableAdapterManager="True">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="tbl_Demo" msprop:Generator_UserTableName="tbl_Demo" msprop:Generator_RowDeletedName="tbl_DemoRowDeleted" msprop:Generator_RowChangedName="tbl_DemoRowChanged" msprop:Generator_RowClassName="tbl_DemoRow" msprop:Generator_RowChangingName="tbl_DemoRowChanging" msprop:Generator_RowEvArgName="tbl_DemoRowChangeEvent" msprop:Generator_RowEvHandlerName="tbl_DemoRowChangeEventHandler" msprop:Generator_TableClassName="tbl_DemoDataTable" msprop:Generator_TableVarName="tabletbl_Demo" msprop:Generator_RowDeletingName="tbl_DemoRowDeleting" msprop:Generator_TablePropName="tbl_Demo">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Id" msdata:ReadOnly="true" msdata:AutoIncrement="true" msdata:AutoIncrementSeed="-1" msdata:AutoIncrementStep="-1" msprop:Generator_UserColumnName="Id" msprop:Generator_ColumnPropNameInRow="Id" msprop:Generator_ColumnVarNameInTable="columnId" msprop:Generator_ColumnPropNameInTable="IdColumn" type="xs:int" />
              <xs:element name="Name" msprop:Generator_UserColumnName="Name" msprop:Generator_ColumnPropNameInRow="Name" msprop:Generator_ColumnVarNameInTable="columnName" msprop:Generator_ColumnPropNameInTable="NameColumn" minOccurs="0">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="10" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
              <xs:element name="Arrived" msprop:Generator_UserColumnName="Arrived" msprop:Generator_ColumnPropNameInRow="Arrived" msprop:Generator_ColumnVarNameInTable="columnArrived" msprop:Generator_ColumnPropNameInTable="ArrivedColumn" type="xs:dateTime" minOccurs="0" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:choice>
    </xs:complexType>
    <xs:unique name="Constraint1" msdata:PrimaryKey="true">
      <xs:selector xpath=".//mstns:tbl_Demo" />
      <xs:field xpath="mstns:Id" />
    </xs:unique>
  </xs:element>
</xs:schema>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Russian Federation Russian Federation
Microsoft certified professional developer (MCPD)

Comments and Discussions