Click here to Skip to main content
15,911,139 members
Home / Discussions / Database
   

Database

 
GeneralRe: Alphabetical sorting - SQL Pin
butchzn27-Sep-04 1:44
butchzn27-Sep-04 1:44 
Questioncopy db diagrams from one sql server to another? Pin
Roger Alsing14-Sep-04 21:42
Roger Alsing14-Sep-04 21:42 
AnswerRe: copy db diagrams from one sql server to another? Pin
Totoo15-Sep-04 9:50
Totoo15-Sep-04 9:50 
GeneralVarbinary field comparisons Pin
cpritt14-Sep-04 8:29
cpritt14-Sep-04 8:29 
GeneralRe: Varbinary field comparisons Pin
Jon Rista14-Sep-04 8:44
Jon Rista14-Sep-04 8:44 
GeneralRe: Varbinary field comparisons Pin
cpritt14-Sep-04 9:52
cpritt14-Sep-04 9:52 
GeneralRe: Varbinary field comparisons Pin
Jon Rista14-Sep-04 13:17
Jon Rista14-Sep-04 13:17 
GeneralRe: Varbinary field comparisons Pin
cpritt14-Sep-04 18:57
cpritt14-Sep-04 18:57 
Thanks for the input and patience to respond to my questions. I tried the GetString(1) and it generated a exception for illegal typecast. Not sure where to go from here. Just in case we are missing each other in the interpretation of what i am trying to do in the code, here is the code in question. Pretty short and simple. I have walked through this step by step and where known sid's are in the sysusers table the executescalar count is still 0 when it should be 1. Of course that could be where my understanding is causing me to blieve the code is not working:

private void GetLoginsNotMapped()
{
int count;
bool sidFound;
string user;
SqlTransaction my_SqlTransaction;
SqlCommand my_Command;
SqlDataReader my_Reader;
SqlConnection my_Connection;
SqlCommand m_Command;
SqlDataReader m_Reader;
SqlConnection m_Connect;
SqlCommand my_SqlCommand;
SqlCommand m_SqlCommand = new SqlCommand();
SqlConnection t_Connection;

try
{
m_Connect = ConnectToServer();
my_Connection = ConnectToServer();
t_Connection = ConnectToServer();

if (sqlSuccess == true)
{
cString = "Select name, sid from master.dbo.syslogins";
my_Command = new SqlCommand(cString,my_Connection);
my_Reader = my_Command.ExecuteReader();

m_SqlCommand.Connection = t_Connection;

while (my_Reader.Read())
{
sidFound = false;
user = my_Reader["name"].ToString(); //Used only for troublshooting

cString = "Select name from master.dbo.sysdatabases";
m_Command = new SqlCommand(cString,m_Connect);
m_Reader = m_Command.ExecuteReader();

while (m_Reader.Read())
{
cString = "Select count(*) from " + m_Reader["name"].ToString() + ".dbo.sysusers ";
cString = cString + "where sid = " + my_Reader.GetString(1) + "";

m_SqlCommand.CommandText = cString;

try
{
count = (int) m_SqlCommand.ExecuteScalar();
if (count > 0 ) sidFound = true;
}
catch (SqlException e)
{
logErrorMessage(serverName,e.Message);
}
}
m_Reader.Close();
m_Command.Dispose();
if (sidFound == false)
{
try
{
my_SqlTransaction = mySqlConnection.BeginTransaction();
my_SqlCommand = mySqlConnection.CreateCommand();
my_SqlCommand.Transaction = my_SqlTransaction;
my_SqlCommand.CommandText = "Insert into tblNotMapped (" +
"serverName, loginName) Values ('" + serverName +
"', '" + my_Reader["name"].ToString() + "') ";
my_SqlCommand.ExecuteNonQuery();
my_SqlTransaction.Commit();
my_SqlTransaction.Dispose();
}
catch (SqlException ex)
{
logErrorMessage(serverName,ex.Message);
}
}
}
my_Reader.Close();
my_Command.Dispose();
m_SqlCommand.Dispose();
}
}
catch (SqlException err)
{
logErrorMessage(serverName,err.Message);
}
}


Thanks ahead of time for any tips can be sent my way.

/cp
GeneralRe: Varbinary field comparisons Pin
Jon Rista15-Sep-04 7:16
Jon Rista15-Sep-04 7:16 
GeneralRe: Varbinary field comparisons Pin
cpritt15-Sep-04 8:54
cpritt15-Sep-04 8:54 
GeneralRe: Varbinary field comparisons Pin
Jon Rista30-Sep-04 18:52
Jon Rista30-Sep-04 18:52 
GeneralExtreme performance issues (SQL Server 2000/ADO.NET/C#) Pin
Jon Rista14-Sep-04 8:14
Jon Rista14-Sep-04 8:14 
GeneralRe: Extreme performance issues (SQL Server 2000/ADO.NET/C#) Pin
Steven Campbell14-Sep-04 9:34
Steven Campbell14-Sep-04 9:34 
GeneralRe: Extreme performance issues (SQL Server 2000/ADO.NET/C#) Pin
Steven Campbell14-Sep-04 9:35
Steven Campbell14-Sep-04 9:35 
GeneralRe: Extreme performance issues (SQL Server 2000/ADO.NET/C#) Pin
Jon Rista14-Sep-04 13:13
Jon Rista14-Sep-04 13:13 
GeneralRe: Extreme performance issues (SQL Server 2000/ADO.NET/C#) Pin
Steven Campbell14-Sep-04 14:08
Steven Campbell14-Sep-04 14:08 
GeneralRe: Extreme performance issues (SQL Server 2000/ADO.NET/C#) Pin
Jon Rista14-Sep-04 14:26
Jon Rista14-Sep-04 14:26 
GeneralWorking with a database Pin
Britnt714-Sep-04 2:17
Britnt714-Sep-04 2:17 
QuestionHow to display message when record is not found? Pin
DotNet13-Sep-04 23:00
DotNet13-Sep-04 23:00 
AnswerRe: How to display message when record is not found? Pin
Colin Angus Mackay14-Sep-04 2:52
Colin Angus Mackay14-Sep-04 2:52 
GeneralRe: How to display message when record is not found? Pin
DotNet14-Sep-04 2:59
DotNet14-Sep-04 2:59 
GeneralRe: How to display message when record is not found? Pin
Steven Campbell14-Sep-04 4:35
Steven Campbell14-Sep-04 4:35 
GeneralRe: How to display message when record is not found? Pin
DotNet14-Sep-04 4:56
DotNet14-Sep-04 4:56 
GeneralSQL Server/Access Import Issue Pin
Ossmer13-Sep-04 21:45
Ossmer13-Sep-04 21:45 
GeneralNew data row in data set- without disturbing IIS ! Pin
aBaste13-Sep-04 20:58
aBaste13-Sep-04 20:58 

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.