Re: Insert date into a datetime column in Visual Basic 2008

Tech-Archive recommends: Speed Up your PC by fixing your registry



Gum wrote:
I need to insert a date (i.e., "2009/05/12 02:46" or
system.datetime.tostring) into a datetime column using ADO. I got an
error saying that there is a problem converting the string into
datetime.
I am using a SQL string "INSERT insertTB([date],[close])
values('cast(dte as datetime)', 'Fnumber')"
How can I do this insert using the most efficient method?

Why would you think the string 'cast(dte as datetime)' could be inserted
into a datetime column? You do realize that's a literal string, don't you? I
think more of your code is necessary to enable someone to solve your
problem.

Are you using ADO or ADO.Net? If the latter:
***canned wrong-newsgroup reply************************
There was no way for you to know it (except maybe by browsing through some
of the previous questions in this newsgroup before posting yours - always a
recommended practice) , but this is a classic (COM-based) ADO newsgroup.
ADO.Net bears very little resemblance to classic ADO so, while you may be
lucky enough to find a dotnet-knowledgeable person here who can answer your
question, you can eliminate the luck factor by posting your question to a
group where those dotnet-knowledgeable people hang out. I suggest
microsoft.public.dotnet.framework.adonet.
..******************************************************************


--
Microsoft MVP - ASP/ASP.NET - 2004-2007
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


.



Relevant Pages

  • Re: Insert date into a datetime column in Visual Basic 2008
    ... Dim conn As SqlConnection ... Dim cmdString As String ... system.datetime.tostring) into a datetime column using ADO. ... Are you using ADO or ADO.Net? ...
    (microsoft.public.data.ado)
  • Insert date into a datetime column in Visual Basic 2008
    ... system.datetime.tostring) into a datetime column using ADO. ... saying that there is a problem converting the string into datetime. ...
    (microsoft.public.data.ado)
  • RE: Query to DB2
    ... Since the ADO code took considerable sniffing around and piecing together, ... Extract data from a Database to Excel ... Dim cn As New ADODB.Connection ... Dim sProv As String, sDS As String, sCon As String, sTable As String, ...
    (microsoft.public.excel.programming)
  • Re: using ado to query the contents of a spreadsheet
    ... Try adding Imex option to connection string for mixed values that is the only ... It is not hard to run a simple macro in front of your ADO code that converts ... Not the most ideal solution when you have a lot of worksheets and the ... 'Create the reference to the ado recordset ...
    (microsoft.public.excel.programming)
  • Re: Insert date into a datetime column in Visual Basic 2008
    ... Dim cmdString As String ... Dim dte As System.DateTime ... wholly contained within the SQL executed on the server. ... ADO, not ADO.Net, so I can't provide a working example for you). ...
    (microsoft.public.data.ado)