我是C#ADO.NET和SQL的新手,有一个我无法想象的问题.我正在尝试DateTime使用C#插入SQL Server.我收到了消息
"从字符串转换日期和/或时间时转换失败"
当程序命中时cmd.ExecuteNonQuery();.对此的任何帮助真的很感激
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AutoLotConnectedLayer;
using System.Configuration;
using System.Data;
namespace AutoLotCUIClient
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("***** The AutoLot Console UI *****\n");
// Get connection string from App.config.
string cnStr =
ConfigurationManager.ConnectionStrings["AutoLotSqlProvider"].ConnectionString;
//bool userDone = false;
//string userCommand = "";
// Create our InventoryDAL object.
InventoryDAL invDAL = new InventoryDAL();
invDAL.OpenConnection(cnStr);
InsertNewCar(invDAL);
#region Insert car
private static void InsertNewCar(InventoryDAL invDAL)
{
// First …Run Code Online (Sandbox Code Playgroud) 我是新手代码,大多数工作都有效,但我无法运行此代码.有人可以帮忙吗?
我试过,using System.Forms但它显示缺少命名空间.当我用using System.Windows.Forms这个消息消失了.它不允许我同时使用它们.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
StreamReader sr = new StreamReader(@"file.csv");
// for set encoding
// StreamReader sr = new StreamReader(@"file.csv", Encoding.GetEncoding(1250));
string strline = "";
String[] _values = null;
int x = 0;
while(!sr.EndOfStream)
{
strline = sr.ReadLine();
_values = strline.Split(',');
if (_values.Length >= 6 && _values[0].Trim().Length > 0)
{
MessageBox.show(_values[1]);
}
}
sr.Close(); …Run Code Online (Sandbox Code Playgroud)