when I try to insert datetime value into a SQL Server database I get this error: Conversion failed when converting date and/or time from character string Code: Table table has 1 datetime column called time. Edit: my table created in msSQL 2012: http://i.imgur.com/TJ3t3y7.png my real code is: Answer The actual problem here is that you’re writing the parameter inside quotes:
Tag: c#
What does SQL Server do with a timed out request?
Suppose that I use C# to run a long running SQL Server stored procedure (lets say 30 minutes). Further suppose that I put a 1 hour timeout period on the query in C# such that if for whatever reason this SP takes longer than expected, I don’t end up monopolizing the DB. Lastly, suppose that this stored procedure has a
How to select distinct year from a datetime column and add the result to a comboBox in C#?
I am using visual studio 2010 and SQL Management Studio R2 Although the sql query works fine in sql management studio. Its throws an exception in visual studio. Out of index exception whem i edit to make any other adjustments it throws Out of format exception. Please Help me. The code is as follows: Answer You’re not selecting tdate but
SQLite, insert variable in my table (c# console app)
I was wondering if it is possible to insert a variable in my SQLite table (like the TheName in the example code) , and if it is how are you able to do it ? Answer You need parameterized queries:
How can I connect C# with Db with App.config?
I need to connect C# with SQL Server database using app.config. My code is: and in app.config I have: but I get an error and I can’t fix it: ConfigurationErrorExeption was Unhandled Configuration system failed to initialize Can anyone help me please ? Answer Try: You’re referencing Conn as the connection string name but referenced it as Test1 in the
Calling Functions in SqlCommand
Can I use Sql Server functions in myCommand.CommandText and why? Answer If you mean, SQL Server user defined functions. Then, yes; you can use it normally like: The reason it works is because this is the way that functions are called in SQL Server directly.
OLEDB reading CSV file returns first column only
I’m trying to read a pipe separated text file. First lines are “BewerberID”|”Druck”|”Druckdatum”|”HistorieID”|”Bearbeiter”|”BewZuBewGruppeID”|”Bemerkung” “12586”|”EinladungOFD.dot …
Using GetSchemaTable() to retrieve only column names
Is it possible to use GetSchemaTable() to retrieve only column names? I have been trying to retrieve Column names (only) using this method, is it possible. This code retrieves a lot of table data unwanted, I only need a list containing column names!: Answer You need to use ExecuteReader(CommandBehavior.SchemaOnly)): SchemaOnly: The query returns column information only. When using SchemaOnly, the
How to Invoke Button click Event of .ascx after checking timeout value using Javascript on its .aspx File
I have 2 Files. One is aspx and its ascx. aspx contains Javascript which calculates count down time for exam. while timer value reaches to 00:00:00 I want to invoke an event “Submit Exam” which is in ascx file. Final Paper.aspx.cs Final Paper.aspx Exam_paper.ascx Answer Make your btnSubmit a public property of your usercontrol, so that it can be accessible
How to fill Dataset with multiple tables?
I’m trying to fill DataSet which contains 2 tables with one to many relationship. I’m using DataReader to achieve this : But I’ve got only one table filled up. How do I achieve my goal – fill both tables? I would like to use DataReader instead DataAdapter, if it possible. Answer If you are issuing a single command with several