DateTime.Min Won't Insert Into SQL Server Mobile 3.0

Jul 7, 2006

Hi all,

In my C# code I have a Class property that takes the value DateTime.Min upon initialisation, but when I try to insert this into the database column (yes, it is DateTime data type :)) I get an 'Unexpected Error' from SQL Server Mobile.

Is this a known?

Tryst

View 3 Replies


ADVERTISEMENT

Create Tables And Insert Data In Sql Server Mobile On Dekstop

Mar 2, 2006

Hello (sorry my bad english, im brazilian)

I was using Visual Studio 2003 and SQL Server CE 2.0 for C# mobile applications. The .sdf database were created in the emulator or in the mobile device itself using Query Analizer.

The application developed need some initial data to run, and this data is obtained executing one service that reads a postgree database, and insert the data in the SQL CE database of the mobile device. But, given the size of the database (maybe 10.000 rows), it tooks too much time (sometimes 6 hours).

Now we are migrating to Visual Studio 2005 and SQL Server 2005 Mobile Edition.

I want to know if its possible to create the .sdf database and load the data into this database on the desktop. Maybe through the execution of a .sql script, or through a service executed on the desktop.

After this, its just upload de .sdf file to the mobile device.

Thanks

Robson

View 8 Replies View Related

How To Set Default Value For Datetime Column In Sql Mobile?

Oct 6, 2006

I try to set a default value (getdate()) for a datetime culomn in sql mobile,
but got error when i insert record:

there was a syntax error in the date format. [expression = getdate()]

may be I can only set a exict date ?

View 3 Replies View Related

SQL Server Mobile Merge Replication Walkthrough, Cant Find The .NET Framework Data Provider For SQL Server Mobile Edition.

Sep 9, 2005

Hi,

View 3 Replies View Related

Insert DateTime Into SQL Server Using C#

Jan 13, 2004

Hi,

I have very little C# experience and I am in over my head here. This script will insert all data into the data base after I have removed all refference to the date.

I know I have to change the datatype in code, but I have tried everything I can think of.

Any suggestion would be greatly appreciated.

The .aspx.cs file is below:



using System;
using System.Configuration;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.IO;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;



namespace News
{
public class AddNews : System.Web.UI.Page
{
protected System.Web.UI.HtmlControls.HtmlInputText txt_news_title;
protected System.Web.UI.WebControls.TextBox txt_news_body;
protected System.Web.UI.HtmlControls.HtmlInputFile txt_news_image;
protected System.Web.UI.WebControls.Button UploadBtn;
protected System.Web.UI.WebControls.Button ResetBtn;
protected System.Web.UI.WebControls.RequiredFieldValidator rfv_news_image;
protected System.Web.UI.WebControls.Label lbl_news_result;

public AddNews() { }


private void Page_Load(object sender, System.EventArgs e)
{}


public void UploadBtn_Click(object sender, System.EventArgs e)
{
if (Page.IsValid) //save the image
{

//news_title
string newsTitle = txt_news_title.Value;

//news_body
string newsBody = txt_news_body.Text;

//news_date
DateTime dtCurrTime = DateTime.Today;
string d = dtCurrTime.ToString();

//news_img & news_imgcontenttype
Stream imgStream = txt_news_image.PostedFile.InputStream;
int imgLen = txt_news_image.PostedFile.ContentLength;
string imgContentType = txt_news_image.PostedFile.ContentType;
byte[] imgBinaryData = new byte[imgLen];
int n = imgStream.Read(imgBinaryData,0,imgLen);

int RowsAffected = SaveToDB( newsTitle,newsBody,d,imgBinaryData,imgContentType);
if ( RowsAffected>0 )
{
//Response.Write("<BR>The Image was saved");
lbl_news_result.Text = "Record was added successfully!";
txt_news_title.Value = "";
txt_news_body.Text = "";
}
else
{
//Response.Write("<BR>An error occurred uploading the image");
lbl_news_result.Text = "Record was NOT added!";
}
}
}

public void Reset_Click(object sender, System.EventArgs e)
{
txt_news_title.Value = "";
txt_news_body.Text = "";
lbl_news_result.Text = "";


}




private int SaveToDB(string newsTitle, string newsBody, string d, byte[] imgbin, string imgcontenttype)
{
//use the web.config to store the connection string
SqlConnection connection = new SqlConnection(ConfigurationSettings.AppSettings["connString"]);


SqlCommand command = new SqlCommand( "INSERT INTO Cover (cover_title,cover_body,cover_date,cover_image,cover_imgcontenttype) VALUES ( @news_title,@news_body,@news_date,@img_data,@img_contenttype )", connection );

SqlParameter param0 = new SqlParameter( "@news_title", SqlDbType.VarChar,50 );
param0.Value = newsTitle;
command.Parameters.Add( param0 );

SqlParameter param1 = new SqlParameter( "@news_body", SqlDbType.VarChar,5000 );
param1.Value = newsBody;
command.Parameters.Add( param1 );

SqlParameter param2 = new SqlParameter( "@news_date", SqlDbType.VarChar,8 );
param2.Value = d;
command.Parameters.Add( param2 );


SqlParameter param3 = new SqlParameter( "@img_data", SqlDbType.Image );
param3.Value = imgbin;
command.Parameters.Add( param3 );

SqlParameter param4 = new SqlParameter( "@img_contenttype", SqlDbType.VarChar,50 );
param4.Value = imgcontenttype;
command.Parameters.Add( param4 );

connection.Open();

int numRowsAffected = command.ExecuteNonQuery();

connection.Close();

return numRowsAffected;
}
}
}




Thanks!

View 5 Replies View Related

Insert Datetime In SQL Server?

Feb 12, 2004

Hi there,

Just a simple question for the .NET geeks out there.....how do I insert datetime format in MS SQL Server 7.0?

Thank you!

View 3 Replies View Related

SQL Server Mobile 2005 Merge Replication Problem On Windows Mobile 5.0

Aug 8, 2006



Dear ppl,

I am writing an application for a device (MDA Pro T-Mobile) having Windows Mobile 5.0 using

-MS .NET Compact Framework 2.0 SP-1
-SQL Mobile 2005.
-VS 2005 .NET

The application uses Merge Replication. The error occurs in the Synchronise() Method of the SqlCeReplication object.

"SQL Server Mobile encountered problems when opening the database."

repl.AddSubscription(AddOption.CreateDatabase);
repl.Synchronize();

I don't understand why I am having this error. It does create the database on AddSubscription() method but it is failing opening the database on Synchronise(). I have also tried uninstalling and then reinstalling all the SQL Mobile components in the following order.

-sqlce30.wce5.armv4i.cab
-sqlce30.repl.wce5.armv4i.cab
-sqlce30.dev.ENU.wce5.armv4i.cab

However, when i run this application on a device(Dell X50 AXIM) with Pocket PC 2003, it runs fine creating the database and sysnchronising it.

The target platform for the project is Windows Mobile 5.0 Pocket PC SDK.

Does any one have any clue what could be the problem ?

Regards
Nabeel

View 6 Replies View Related

Problem Using SQL Server Mobile 2005 With Windows Mobile 5 Application

Mar 23, 2006

Hello,

I am developping a non-managed C++ application for PocketPC using a SQL Server mobile database.

The application is compiled for PocketPC 2003 and uses SQL Server Mobile v2. I use Visual Studio 2005. But I need to compile the application for Windows Mobile 5.0 devices. So I installed the WM5 SDK and had the WM5 into my project configuration.

The "ssceoledb.h" which I include incluses the "transact.h" file. But my problem is that this file is only provided with the PocketPC 2003 SDK and not in the WM5 SDK.
So I cannot use the WM5 configuration project with SQL Server. I also tried with the last SQL Server Mobile 2005 (ie v3.0) and the "ssceoledb30.h" also includes "transact.h".

Did I miss something to install ?
Do you know how I can resolve the problem ?

By advance, thank you for any answer.

--
Gregoire

View 9 Replies View Related

Cannot Build SQL Server Mobile Solution For Windows Mobile 5

May 18, 2006

Using MS VS 2005 (incl SQL Server Mobile)
MS Pocket PC 2005 SDK

I am working on a project that builds for Pocket PC on both Mobile 2003 and Mobile 5. The project uses/will use SQL Server Mobile to store local data.

Project created from new with support for both platforms. I include required header files ssceerr30.h and ssceoledb30.h.

Project builds fine in WM2003 configuration, release and debug.

When I build for WM5 the compiler cannot find the header file transact.h. This is included from within ssceoledb30.h. Same as under WM2003.

In WM2003 configuration if I highlight the ssceoledb30.h include in Visual Studio and open the header, it takes me to <Visual Studio dir>SmartDevicesSDKSQL ServerMobilev3.0. I then locate the include for transact.h and do the same, which takes me <Visual Studio dir>SDKPocketPC2003include. The file exists.

If I repeat the above 'browsing' under the WM5 configuration, ssceoledb30.h takes me to a different copy in the WM5 SDK directory. There is no diff between the file here and the other copy used by WM2003. If I attempt to open transact.h - file does not exist.

Fix (which I'm not too sure about, i.e. is it OK?) - If I copy transact.h to the WM5 SDK directory, the project builds.

Why has transact.h disappeared from WM5 SDK?
I can find no ref's to this problem anywhere. Is my installation of the WM5 SDK corrupt? What else could I be missing?
Is there a sample for SQL Server mobile (like the NorthwindOLEDB sample) that comes configured to build for WM5?

View 1 Replies View Related

SQL Server Mobile Tutorial And Getting Proper Mobile DB Installation

Apr 24, 2006

Hi folks, I'm new to Windows Mobile progamming, and new to this forum. Apologies in advance if I'm asking a boneheaded question, but I've done searches and can't find anything directly applicable to my problem.

I'm currently walking through the published MS tutorial in setting up an SQL Server 2005 Mobile application that subscribes to a publication on SQL Server 2005 to exchange information.

I've gotten almost all the way through... successfully set up the server components, creating the publication, etc. On the mobile side, I've been able run the cab files to install the SQL Mobile components and to create the project, add the reference to the dll, and instantiate an engine object. It compiles.

The step in the tutorial after that, though, where you specify the data source from the "data" menu, I've got a problem. When I try to use the "new connection" dialog from choosing the data connection, "MS SQL Server Mobile Edition" doesn't show up as a choice. I've tried choosing any of the other combinations, and in teh subsequent "Connection properties" section my database, SQLMobile (as in their sample) is available, but I get an error when I choose it and click OK. Clicking on "Test Connection" gives me a connection successful message.

My guess is that something about the Mobile server side components is not installed correctly on my development machine, but honestly I have no idea how to begin to fix it. Has anyone seen this problem before and know how to resolve it?

Your time and any knowledge sharing is greatly appreciated.
Thank you,
-Dana

View 8 Replies View Related

Howto Insert A Null DateTime Into A Sql Server 2005 Database

Apr 2, 2008

I'm importing data form an Excel file to a Sql Server Database. Some of the data imported represents time as a double type so i convert the times into DateTime to be inserted into the database. The time values that aren't available in the Excel file are 0.. so what i want to do is insert null into the database for all the values that are 0 in the excel file... How do i do that based on this code i have so far:protected void ButtonImport_Click(object sender, EventArgs e){PanelUpload.Visible = false;PanelView.Visible = false;PanelImport.Visible = true;LabelImport.Text = "";OleDbCommand objCommand = new OleDbCommand();objCommand = ExcelConnection(); OleDbDataReader reader;reader = objCommand.ExecuteReader(); while (reader.Read()){DateTime? in_1 = null;DateTime? out_1 = null;DateTime? in_2 = null;DateTime? out_2 = null;   int emp_id = Convert.ToInt32(reader["emp_id"]);DateTime date_entry = Convert.ToDateTime(reader["date_entry"]);if (Convert.ToDouble(reader["in_1"]) != 0)in_1 = ConvertDoubleToDateTime((double)reader["in_1"]);if (Convert.ToDouble(reader["out_1"]) != 0)out_1 = ConvertDoubleToDateTime((double)reader["out_1"]);if (Convert.ToDouble(reader["in_2"]) != 0)in_2 = ConvertDoubleToDateTime((double)reader["in_2"]);if (Convert.ToDouble(reader["out_2"]) != 0)out_2 = ConvertDoubleToDateTime((double)reader["out_2"]); ImportIntoAttendance(emp_id, date_entry, in_1, out_1, in_2, out_2);} reader.Close();}protected void ImportIntoAttendance(int emp_id, DateTime date_entry, DateTime? in_1, DateTime? out_1, DateTime? in_2, DateTime? out_2){ SqlDataSource AttendanceDataSource = new SqlDataSource();AttendanceDataSource.ConnectionString = ConfigurationManager.ConnectionStrings["SalariesConnectionString1"].ToString();AttendanceDataSource.InsertCommandType = SqlDataSourceCommandType.Text;AttendanceDataSource.InsertCommand = "INSERT INTO Attendance (emp_id, date_entry, in_1, out_1, in_2, out_2) " +"VALUES ('" + emp_id + "', '" + date_entry + "', '" + in_1 + "', '" + out_1 + "', " +"'" + in_2 + "', '" + out_2 + "')"; int rowsAffected = 0;try{rowsAffected = AttendanceDataSource.Insert();}catch(Exception ex){LabelImport.Text += "<font color=red>" + ex + "</font><br />";} }private DateTime ConvertDoubleToDateTime(double dbTime){string[] SplitTime = dbTime.ToString().Split('.');string hours = SplitTime[0];string minutes = String.Empty;string time = String.Empty; if (dbTime.ToString().IndexOf('.') != -1){if (SplitTime[1].Length >= 1){if (SplitTime[1].Length == 1)minutes = Convert.ToString(Convert.ToDouble(SplitTime[1]) * 10);else if (SplitTime[1].Length > 1)minutes = SplitTime[1];}}elseminutes = "00";time = hours + ":" + minutes;return Convert.ToDateTime(time);}

View 3 Replies View Related

SQL Server 2005 Mobile Edition ANd SQL Server CE - SHould I Have Uninstalled Mobile First ?

Sep 16, 2007



Hi:

When I try and connecto to SQL CE I always get an invalid operation exception. I"m afraid that I did not follow the proper install for Orcas Beta 2. I can't remember if I was supposed to uninstall SQL Mobile 2005 first or not.

All I know is when I try and use my SQL CE I can't connecto to a DB / sdf file ?

Any help would be appreciated I"m just starting to use SQL CE.

thanks
mark

View 2 Replies View Related

Creating A Mobile Application With SQL Server Mobile - FIX

Jul 21, 2006

This is a great tutorial and it's a shame one of the more important steps was missed.
In the €œCreate the snapshot user€? section you you find the steps to create the snapshot_agent account. Then in the €œCreate the snapshot folder€? section you find the share and folder permissions. However, at no point do the instructions advise you about adding the snapshot_agent to the SQL Server Logins. The result is that agent cannot perform the initial snapshot but you won't find this out until 50 steps later after Step 10 in the section  €œCreate a new subscription".
 
To get back on track, openthe Object Explorer's Security section and add the snapshot_agent to your logins. Then using the "User Mappings", set an appropriate level for the SQLMobile database role. Once completed you then need to run the agent.
 
Right-click the SQLMobile publication you created and select "View Snapshot Agent status". From that dialog you can select "Start" to run the agent. When it completes, you can return to the tutorial section "Create a new subscription" and continue with the tutorial.
 

 

View 4 Replies View Related

Creating A Mobile Application With SQL Server Mobile

Nov 3, 2007

I am studying the tutorial in SQL Server 2005 Mobile Edition Books Online, and the topic is Creating a Mobile Application with SQL Server Mobile. I have got a problem when creating a new subscription after created a new SQL Server Mobile database. And the problem is shown below:

New Subscription Wizard

- Beginning Synchronization (Success)

- Synchronizing Data (100%) (Error)
Messages
* Failure to connect to SQL Server with provided connection information. SQL Server does not exist, access is denied because the IIS user is not a valid user on the SQL Server, or the password is incorrect.
HRESULT 0x80004005 (29061)

* 無法完�作業。


- Finalizing Synchronization (Stopped)

- Saving Subscription Properties (Stopped)

Before I have met this problem, I have finished all the task. And I can browse the localhost web site by using anonymous account even I use internet explorer or browse the directly in IIS.

Does anyone can solve it?? Thank you very much~~~

View 3 Replies View Related

Can't Insert Binary Data Into Sql Mobile

Jul 9, 2006

Hi guys, I'm having a problem inserting a file into a SQL Mobile table.

I'm updating the table via a tableadapter designed through the Dataset designer in VS2k5.

The SQL used to insert is "Insert into TestTable (itemid,itemdata) values (@itemid,@itemdata)"

Where ItemID is a GUID, and ItemData is an Image field. The tableadapter has typed the parameters as GUID and Binary properly already.

Only problem is when I actually call the command with a byte array containing my file, I get a "Byte truncation" error message.

I remember this working properly in SQL CE 2.0 but so far I don't seem to get it to work in SQL mobile, anyone got any pointers?

View 3 Replies View Related

(SQL Mobile)Can SELECT, But Cannot INSERT/UPDATE. Why Not?

Sep 27, 2006

I'm just getting started with using SQL Server Mobile while creating a handheld app using Visual Studio 2005. So far, I have succeeded in RETRIEVING data from the mobile database, but I don't understand why my INSERT nor UPDATE statements will not work. (I'm assuming they don't work, because after I run my code via the debugger, I oddly get no error message, but when I "open" the table in the Server Explorer, I do not see my expected results. Do I need to do some kind of "commit" or something? Here's my code. Thanks for any help! - Sue

-------------------------------------------

'Create SQL statement:
Dim strSQL As String
strSQL = "INSERT INTO MyTable (col1, col2) VALUES ('yucky', 'poo')"

'Create DB connection:
Dim connDB As New System.Data.SqlServerCe.SqlCeConnection
connDB.ConnectionString = ("Data Source =" _
+ (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.GetName.CodeBase) + "SueUWM.sdf;"))

'Create DB command:
Dim cmndDB As New System.Data.SqlServerCe.SqlCeCommand(strSQL, connDB)

'Open the connection:
connDB.Open()

'Execute the command:
Dim intRecordsAffected As Integer
Try
intRecordsAffected = cmndDB.ExecuteNonQuery()

If intRecordsAffected <> 1 Then
MessageBox.Show("Unable to insert into database.")
End If
Catch ex As Exception
MessageBox.Show(ex.ToString, "Insert Error")
End Try

'close the DB connection:

connDB.Close()

-------------------------------------------

View 1 Replies View Related

SQL Mobile 3.0 (Update And Insert Question)

Feb 15, 2007

Is it possible If I use insert query to insert a record, but the record is already exist, it will automatically change insert to update?

And

I have a row: customer_name, last_update

is it possible to use sql to check if the customer_name I want to update is the same as the customer_name in database, it can automatically stop the update?



View 1 Replies View Related

Using RDA To Insert An Image Type From SQL Mobile To SS2005

May 10, 2006

Hiya, last one (for a while), I swear. I'm getting the hang of this now (famous last words).



I've got a data file saved as an image type in my SQL Mobile database,
and I'm trying to send it over to my SS2005 Server via RDA, which seems
the simplest way possible. The application will only have
periodic rows to send over and insert into the Server's DB, so it seems
like doing a merge or a push is unnecessary overhead.



Is there some way to include parameters in the SQL string argument to
the method SubmitSQL? Or, embed the byte array into the SQL string? For
the life of me, I can't figure out how to do this.



So, if column data has type image, my statement would look like what?


string sSQL = "INSERT INTO sensor_stream (data) VALUES (what goes here?)";
rda.SubmitSql(SQL, strSQLConn);



.....

I've seen the solution being able to assign the image by using
parameters, but it seems that solution is not an option in this case?

Thank you in advance for your time and effort, I appreciate any and all help very much.

-Dana

View 5 Replies View Related

Insert GUID Into SQL Mobile Database Table Field

Feb 17, 2006



Hi,

I have created a database in the SQL Server 2005 and the same database in sql mobile. I have a field, which has a GUID and uniqueidentifier, when i tried to insert the same data which is there in sql server 2005 database into sql mobile database it is giving me error as below

Major Error 0x80040E14, Minor Error 25501

> INSERT INTO TypeValue (TypeValue_ID,DisplayValue,TypeName,OrderIndex,IsActive)

VALUES (b6483fe1-1118-4ba1-9106-0069715a75c0,Asian,ETHNICITY,1,TRUE)

There was an error parsing the query. [ Token line number = 2,Token line offset = 24,Token in error = ba1 ]

Please suggest me any solution.

Thank you,

Prashant

View 1 Replies View Related

Grabbing Mobile Data For Desktop Ui (update/delete/insert)

Mar 11, 2008

Howdy,

Am trying to find a way to insert/update/delete data in a SQL mobile database on a Windows CE 5.0 device FROM a desktop PC.

This situation is completely stand alone, no network (apart form device/desktop), no GPRS etc etc etc.

I've looked at RDA but i dont believe it fits my app. (pulling data from a 2005 server that doesnt exist doesnt really help me much, push can't be used without a pull which kills the idea.)

The goal is a UI on the desktop that can manipulate data in the SQL mobile Database.

I've tried all i can find/think off in relation to this but to no avail.

My latest attempt has been using the simplest method possible (using a VS wizard datasource to the devices DB and tryign to whack that on a form) but this just creates a "Path not found. Check the directory for the database [Path = Mobile Device/ce_swipe/TestDB.sdf".

View 5 Replies View Related

Insert Datetime, Using ADO.net VB.net

Feb 16, 2008

Hello there,I got a little code there are inserting a record into my msSQL database..But i cant insert the datetime, for one reason?The problem is in line 7 () where i want to insert DateTime.Now 1 Protected Sub SendPmTilAfviste(ByVal modtager As String, ByVal festID As String)
2 ' Connection
3 Dim conn As SqlConnection = New SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|ASPNETDB.MDF;Integrated Security=True;User Instance=True")
4 conn.Open()
5
6 ' SQL-kommandoen
7 Dim cmd As SqlCommand = New SqlCommand("INSERT INTO marcisoft_PMsystem(laest,fra,modtager,sendt,overskrift,besked) VALUES('<b>Ny!</b>','webmaster1','" + modtager + "','" + DateTime.Now + "','A headline','text text the id " + festID + "')", conn)
8 cmd.ExecuteNonQuery()
9
10 conn.Close()
11 conn = Nothing
12
13 End Sub
 If i using with ' aroundIt show up with a error, out of range..And if i dont, it show up with another error, problem near 02(02 could be the clock or the month, think clock)Hope someone knows how this is done..

View 4 Replies View Related

Millisecond Values Missing When Inserting Datetime Into Datetime Column Of Sql Server

Jul 9, 2007

Hi,
I'm inserting a datetime values into sql server 2000 from c#

SQL server table details
Table nameate_test
columnname datatype
No int
date_t DateTime

C# coding
SqlConnection connectionToDatabase = new SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=testdb;Integrated Security=SSPI");
connectionToDatabase.Open();
DataTable dt1 = new DataTable();
dt1.Columns.Add("no",typeof(System.Int16));
dt1.Columns.Add("date_t", typeof(System.DateTime));
DataRow dr = dt1.NewRow();
dr["no"] = 1;
dr["date_t"] = DateTime.Now;
dt1.Rows.Add(dr);
for(int i=0;i<dt1.Rows.Count;i++)
{
string str=dt1.Rows["no"].ToString();
DateTime dt=(DateTime)dt1.Rows["date_t"];
string insertQuery = "insert into date_test values(" + str + ",'" + dt + "')";
SqlCommand cmd = new SqlCommand(insertQuery, connectionToDatabase);
cmd.ExecuteNonQuery();
MessageBox.Show("saved");
}
When I run the above code, data is inserted into the table
The value in the date_t column is 2007-07-09 22:10:11 000.The milliseconds value is always 000 only.I need the millisecond values also in date_t column.
Is there any conversion needed for millisecond values?

thanks,
Mani

View 3 Replies View Related

How To Insert A Datetime To Sql Sever

Aug 30, 2006

Hi everyone,I need help in inserting a date time string to sql sever.  For example, how do you insert textbox1.text="2006-08-30 09:00:00" into a datatable column names starttime (type datetime) in sql sever?  How do I covert the format of this string before I do the insert?Thanks.a123.

View 2 Replies View Related

How To Insert A Datetime Into Sql Sever

Aug 30, 2006

Hi everyone,How do you insert this string value lable1.text="2006-08-30 09:00:00" into  a data column like startdate (type: datetime) in sql sever?How do I convert this string value before I insert it into sql sever? Thank you very much.a123.

View 1 Replies View Related

Insert NULL Value Into DateTime

Dec 11, 2006

Does anyone have a simple way of inserting a NULL value into sql 2000 datetime. I'm using vb.net.
All I want is if the user does not enter a date in a textbox to to send a NULL value to the DB instead of having the db enter the default value as 1/1/1900.
Thank you

View 3 Replies View Related

Datetime Format (insert From Vb6)

Apr 12, 2000

I'm still having a problem inserting date fields into sql server.

I don't understand how it accepts datetime.

I have all of my date columns defined with datetime format and all of the dates are coming out as the default of: 01/01/1900.

I tried to insert the data as string and sql server doesn't understand that format.
Here's some of the code:

We're going from flat VSAM files to an sql server database.
This is one huge sql insert statement with about 75 fields being loaded into a table so I'll only post one the date fields.
Here's where I call the String functions from:

First, I have to uncomp the field from binary to String:

ls_sdate = Right$(CompToStr(bufMast.Name_Chg_Date), 8)

And then I send this string to my Convert_Date function:

lsDet1 = Trim$(lsDet1) & Convert_Date(ls_sdate) & ","

(lsDet1 is a concatenated String of the SQL Values to be inserted)

And Here are the two functions:
The date field is coming in like: 1991112 where if the first character is a 1, the year is 1900 and if the first character is a 0, the year is 2000.
I get correct fields in my message box like 1996/12/31 but then I don't know what sql server does to it in datetime format.
When I check the database table it looks like: 01/12/1900

Maybe there is something wrong with my Convert_Date function;

__________________________________________________ ____________

Public Function CompToStr(aCompdata() As Byte) As String
'This is one way in which you can unpack a comp field. As I mentioned,
'you might be better off designing a flexible class to do the
'conversions. At minimum, this function should be expanded to
'accept a data picture as a param (decimal placement and so on).

Dim lsRtnStr As String
Dim lsHoldStr As String
Dim llCount As Long

For llCount = 1 To (UBound(aCompdata) + 1) Step 1 'loop thru the passed array.
lsHoldStr = Hex(aCompdata(llCount - 1)) 'Convert the byte to a Hex string.
If Len(Trim$(lsHoldStr)) = 1 Then 'if the highorder nibble was 0
lsHoldStr = "0" & Trim$(lsHoldStr) 'pad it with a leading zero.
End If
lsRtnStr = lsRtnStr & lsHoldStr 'Concat it to the return string.
lsHoldStr = "" 'clear the var for the next pass.
Next
lsRtnStr = Replace$(lsRtnStr, "C", " ") 'Positive sign replacement.
lsRtnStr = Replace$(lsRtnStr, "D", "-") 'Negative sign replacement.
lsRtnStr = Replace$(lsRtnStr, "F", " ") 'Unsigned - implicit positive.
lsRtnStr = Trim$(lsRtnStr)

llCount = 0
llCount = InStr(1, lsRtnStr, "-")

If llCount > 0 Then
lsRtnStr = Right$(lsRtnStr, 1) & Left$(lsRtnStr, (Len(lsRtnStr) - 1))
End If
CompToStr = lsRtnStr 'Return the hex string.
End Function
__________________________________________________ ___________________

Public Function Convert_Date(ByRef ls_sdate As String) As String

'incoming date
Dim ls_scent
, ls_smonth, ls_sday, ls_syear As String

ls_scent = Left(ls_sdate, 1)
ls_syear = Mid(ls_sdate, 2, 2)
ls_smonth = Mid(ls_sdate, 4, 2)
ls_sday = Right(ls_sdate, 2)

If (ls_sday = "00") Then
ls_sdate = "0000"
ElseIf (ls_scent = 0) Then
'ls_sdate = ls_smonth & "/" & ls_sday & "/" & "19" & ls_syear
ls_sdate = "19" & ls_syear & "/" & ls_smonth & "/" & ls_sday
ElseIf (ls_scent = 1) Then
'ls_sdate = ls_smonth & "/" & ls_sday & "/" & "20" & ls_syear
ls_sdate = "20" & ls_syear & "/" & ls_smonth & "/" & ls_sday
End If

Convert_Date = ls_sdate

End Function
__________________________________________________ ____________

View 1 Replies View Related

Trigger: Insert Datetime

Dec 14, 2005

I'm new to SQL and I'm trying to write a trigger to input the current date/time only on insert.

Can someone help, it seems my syntax is wrong. I've tried it many different ways.

Here's my latest:

select * from inserted set productiondetail.datestamp = getdate(now)

Thanks,

Ronna

View 14 Replies View Related

INSERT Statement For Datetime .

Feb 9, 2005

In Oracle , v can use select and insert for a date column as below:

for select :
----------------------------------------------------------------
select A,to_char(CDATE,'DD-MM-YY:HH:MI:SS AM') from db.table1;

for insert:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
insert into db.table1
(A,CDATE)
values
( 2, TO_Date('20/01/2005 11:08:33 PM', 'DD/MM/YYYY HH:MI:SS AM'));
----------------------------------------------------------------


But How v can use datetime in MSSQL Server ?
What are the corresponding select and insert statement in this ?

Any one have idea in this ?

thanks

View 4 Replies View Related

Insert / Update Datetime

Sep 19, 2007

Hello All,

I am trying to insert birthdate "15/05/1981 10:45:14" into Birthday field from table. But I am receiving errror as follows

The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value.The statement has been terminated.

Does anybody know, how can I insert Or update this date?
Thanks in advance

--kneel

View 5 Replies View Related

Insert Datetime Problem

Jul 23, 2005

How do i insert this string "23:58:44.000 UTC Wed May 11 2005" into thedatabase with datetime data format...I tried using:insert into table (startime) values ('23:58:44.000 UTC Wed May 112005')but got Syntax error converting datetime from character string error.So how do i do it??? Thx.

View 1 Replies View Related

Insert/select Datetime

Apr 4, 2008



Hello,
What is the query for inserting a data and time value for sql ce?
and how can i select the rows that are between 2 date values?
have tried everything but cant make it work..
thnx in advance.
by the way i am using sql mobile 2005 and vs2005..

View 4 Replies View Related

INSERT NULL Value + DateTime

Dec 10, 2007

Hi,

If a datetime variable is empty I want to insert null into the database table.

How do i do this? Below code doesn't work. Get this error...
Cannot implicitly convert type 'System.DBNull' to 'System.DateTime'




Code Block
if (myDataGridView.Rows[iRow].Cells["myDateDataGridViewTextBoxColumn"].Value.ToString() != "")
{
myDateReport = DateTime.Parse(myDataGridView.Rows[iRow].Cells["myDateDataGridViewTextBoxColumn"].Value.ToString());
}
else
{
myDateReport = DBNull.Value;
}

View 2 Replies View Related

SQL Mobile 2005 Replication - SQL Mobile DLL Could Not Be Loaded - Error 28559

Jun 15, 2006

I am migrating a pocket PC application from VS 2003 to VS 2005 and a few weeks ago I hit the following problem when replicating

A SQL Mobile DLL could not be loaded. Reinstall SQL Mobile. [ DLL Name=sqlceca30.dll]

Scanning forums for help I saw that other people had had this problem and one

http://www.eggheadcafe.com/aspnet_answers/NETFrameworkCompactFramework/Feb2006/post25814466.asp

suggested that this problem could be circumvented by getting the replication object early and then continuously using the same object for subsequent replications.

I did this and it works a lot better now but ever so often I get another error which is

Native Error 28559 SQL Mobile encountered problems when opening the database

My only option at this point is to stop and start the application which cures the problem.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved