public void ServiceInfo(int id) { string conn = Connection.ConnectionString; //"Data Source=IN-WKS-410;Initial Catalog=MSNETDB;Integrated Security=True;Pooling=False"; SqlConnection mycon = new SqlConnection(conn); mycon.Open(); foreach (DataGridViewRow row in dataGridView1.Rows) { string DisplayName = row.Cells[3].Value.ToString(); string ServiceName = row.Cells[4].Value.ToString(); string Status = row.Cells[5].Value.ToString(); string ServiceType = row.Cells[6].Value.ToString(); int UserId; SqlCommand com = new SqlCommand(conn, mycon); //Insert System table ID if (UpdateServices(UserId)) { com.CommandText = "insert into ServiceInfo(DisplayName,ServiceName,Status,ServiceType,UserId)values('" + DisplayName + "','" + ServiceName + "','" + Status + "','" + ServiceType + "'," + id + ")"; } else { com.CommandText = "UPDATE ServiceInfo SET" + " DisplayName='" + DisplayName + "',ServiceName='" + ServiceName + "',Status='" + ServiceType + "',ServiceType='" + ServiceType + "',UserId='"+UserId +"' Where UserId='" + UserId + "'"; } com.ExecuteNonQuery(); com.Parameters.Clear(); com.Dispose(); } mycon.Close(); mycon.Dispose(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)