Почему я не могу отправить данные на SQL server?
I am trying make an application which when installed in other system, has to collect details and send to my SQL server. In SQL Server, I have made all columns as varchar(70). I thought the problem was with datatypes, so I decided to remove OSInstallDate and LastBootUpTime in the below code and check. But still other data are not being inserted. There is no problem with sql connection as I have checked it already. If there's any other way of collecting all these data and sending to my database, I would be interested.
Что я уже пробовал:
SelectQuery Sq1 = new SelectQuery("Win32_OperatingSystem"); ManagementObjectSearcher objOSDetails1 = new ManagementObjectSearcher(Sq1); foreach (ManagementObject mo1 in objOSDetails1.Get()) { OperatingSystem = mo1["caption"].ToString(); ServicePack = mo1["csdversion"].ToString(); OSVersion = mo1["version"].ToString(); OSArchitecture = mo1["OSArchitecture"].ToString(); OSSno = mo1["serialnumber"].ToString(); OSInstallDate = mo1["InstallDate"].ToString(); OSDescription = mo1["Description"].ToString(); LastBootUpTime = mo1["LastBootUpTime"].ToString(); SPMajorVersion = mo1["ServicePackMajorVersion"].ToString(); RegUser = mo1["RegisteredUser"].ToString(); OSStatus = mo1["status"].ToString(); } cmd1 = new SqlCommand("INSERT INTO [dbo].[OSInfo]([LastUpdatedOn],[IPAddress],[OperatingSystem],[ServicePack],[OSVersion],[OSArchitecture],[OSSno],[OSInstallDate],[Description],[LastBootUpTime],[SPMajorVersion],[RegUser],[OSStatus]) VALUES (getdate(),'" + IPA + "','" + OperatingSystem + "','" + ServicePack + "','" + OSVersion + "','" + OSArchitecture + "','" + OSSno + "','" + OSInstallDate + "','" + OSDescription + "','" + LastBootUpTime + "','" + SPMajorVersion + "','" + RegUser + "','" + OSStatus + "')", con); int numrows1 = cmd1.ExecuteNonQuery();