Click here to Skip to main content
15,896,493 members
Home / Discussions / C#
   

C#

 
GeneralRe: Problem with SQLDataReader and Insert command Pin
Pete O'Hanlon22-Nov-11 0:37
mvePete O'Hanlon22-Nov-11 0:37 
GeneralRe: Problem with SQLDataReader and Insert command Pin
CCodeNewbie22-Nov-11 1:13
CCodeNewbie22-Nov-11 1:13 
GeneralRe: Problem with SQLDataReader and Insert command Pin
Pete O'Hanlon22-Nov-11 3:03
mvePete O'Hanlon22-Nov-11 3:03 
GeneralRe: Problem with SQLDataReader and Insert command Pin
CCodeNewbie22-Nov-11 9:50
CCodeNewbie22-Nov-11 9:50 
GeneralRe: Problem with SQLDataReader and Insert command Pin
Pete O'Hanlon22-Nov-11 10:20
mvePete O'Hanlon22-Nov-11 10:20 
GeneralRe: Problem with SQLDataReader and Insert command Pin
CCodeNewbie22-Nov-11 11:43
CCodeNewbie22-Nov-11 11:43 
GeneralRe: Problem with SQLDataReader and Insert command Pin
Pete O'Hanlon22-Nov-11 22:51
mvePete O'Hanlon22-Nov-11 22:51 
GeneralRe: Problem with SQLDataReader and Insert command Pin
CCodeNewbie22-Nov-11 23:06
CCodeNewbie22-Nov-11 23:06 
Create Identifying name
string c = System.Environment.MachineName;
string Domain = System.Net.Dns.GetHostName();
ManagementObjectSearcher SerialNo = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM_
Win32_SystemEnclosure");
foreach (ManagementObject querySN in SerialNo.Get())
{
string SN = (querySN["SerialNumber"].ToString());
string SysIdent = c + SN + "@" + Domain;

Check if ID exists by looking for Identifying name - string SysIdent
using(SqlCommand selectname = new SqlCommand("SELECT COUNT(1) FROM dbo.SysIdent WHERE_
FullName = @SysIdent", IdentSys));

If name isn't found, insert it into the table
using(SqlCommand newname = new SqlCommand("INSERT INTO dbo.SysIdent(FullName)_
VALUES(@FullName)", InsertSys);

Reconnect to table to get the ID number associated with the name
SqlCommand GetID = new SqlCommand("SELECT * FROM dbo.SysIdent WHERE FullName = @SysIdent", selectID);

set the system's id
int mySysId = myID;
GeneralRe: Problem with SQLDataReader and Insert command Pin
Pete O'Hanlon23-Nov-11 0:53
mvePete O'Hanlon23-Nov-11 0:53 
GeneralRe: Problem with SQLDataReader and Insert command Pin
CCodeNewbie23-Nov-11 1:12
CCodeNewbie23-Nov-11 1:12 
GeneralRe: Problem with SQLDataReader and Insert command Pin
Pete O'Hanlon23-Nov-11 1:22
mvePete O'Hanlon23-Nov-11 1:22 
GeneralRe: Problem with SQLDataReader and Insert command Pin
CCodeNewbie23-Nov-11 10:19
CCodeNewbie23-Nov-11 10:19 
GeneralRe: Problem with SQLDataReader and Insert command Pin
Pete O'Hanlon23-Nov-11 23:44
mvePete O'Hanlon23-Nov-11 23:44 
GeneralRe: Problem with SQLDataReader and Insert command Pin
CCodeNewbie24-Nov-11 9:55
CCodeNewbie24-Nov-11 9:55 
GeneralRe: Problem with SQLDataReader and Insert command Pin
Pete O'Hanlon24-Nov-11 22:30
mvePete O'Hanlon24-Nov-11 22:30 
GeneralRe: Problem with SQLDataReader and Insert command Pin
CCodeNewbie24-Nov-11 22:32
CCodeNewbie24-Nov-11 22:32 
GeneralRe: Problem with SQLDataReader and Insert command Pin
Pete O'Hanlon24-Nov-11 22:48
mvePete O'Hanlon24-Nov-11 22:48 
GeneralRe: Problem with SQLDataReader and Insert command Pin
CCodeNewbie24-Nov-11 22:51
CCodeNewbie24-Nov-11 22:51 
GeneralRe: Problem with SQLDataReader and Insert command Pin
CCodeNewbie25-Nov-11 10:51
CCodeNewbie25-Nov-11 10:51 
GeneralRe: Problem with SQLDataReader and Insert command Pin
Pete O'Hanlon30-Nov-11 5:34
mvePete O'Hanlon30-Nov-11 5:34 
GeneralRe: Problem with SQLDataReader and Insert command Pin
CCodeNewbie30-Nov-11 8:55
CCodeNewbie30-Nov-11 8:55 
GeneralRe: Problem with SQLDataReader and Insert command Pin
Pete O'Hanlon30-Nov-11 11:13
mvePete O'Hanlon30-Nov-11 11:13 
GeneralRe: Problem with SQLDataReader and Insert command Pin
CCodeNewbie30-Nov-11 11:21
CCodeNewbie30-Nov-11 11:21 
GeneralRe: Problem with SQLDataReader and Insert command Pin
Pete O'Hanlon30-Nov-11 11:29
mvePete O'Hanlon30-Nov-11 11:29 
AnswerRe: Problem with SQLDataReader and Insert command Pin
Pete O'Hanlon21-Nov-11 8:48
mvePete O'Hanlon21-Nov-11 8:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.