Click here to Skip to main content
15,900,816 members
Home / Discussions / C#
   

C#

 
AnswerRe: BinaryWriter.Write(string) Pin
Ista13-Dec-05 2:33
Ista13-Dec-05 2:33 
AnswerRe: BinaryWriter.Write(string) Pin
Daniel Grunwald13-Dec-05 4:15
Daniel Grunwald13-Dec-05 4:15 
GeneralRe: BinaryWriter.Write(string) Pin
Daniel Monzert14-Dec-05 6:33
Daniel Monzert14-Dec-05 6:33 
GeneralRe: BinaryWriter.Write(string) Pin
Daniel Grunwald14-Dec-05 6:40
Daniel Grunwald14-Dec-05 6:40 
QuestionPerfMon: Where are my counters? Pin
Salil Khedkar12-Dec-05 23:50
Salil Khedkar12-Dec-05 23:50 
AnswerRe: PerfMon: Where are my counters? Pin
S. Senthil Kumar13-Dec-05 1:06
S. Senthil Kumar13-Dec-05 1:06 
GeneralRe: PerfMon: Where are my counters? Pin
Salil Khedkar13-Dec-05 20:06
Salil Khedkar13-Dec-05 20:06 
QuestionC# And ADO.NET N-Tier Help Pin
systemnyc12-Dec-05 23:15
systemnyc12-Dec-05 23:15 
Hi,

I am developing the Date Access Tier. Can soem one help me with a stand alone SqlDataReader. I have created a connection class and would like to then open the connection in the Data Access class, but I am stuck. Every piece of material that I read, just implements code in the same class. I Know that i can drag and drop the connection and all but i don't want to do that. I am new to coding.

<code>
public class Connectivity
{

private string ServerName = "";
//private string prvWINNTAuth = "";
//private string sDBInfo = "";
//private string sStaticDataConnectionString = "";
private string DatabaseName = "";

public Connectivity()
{
DatabaseName = "(Local)";
ServerName = "DataBase";
}
public SqlConnection SetConnection()
{
return GetConnection();
}

private string UserName
{
get{return prvUserName;}
set{prvUserName = value;}
}

private string Password
{
get{return prvPassword;}
set{prvPassword = value;}
}

private string DatabaseName
{
get{return prvDatabaseName;}
set{prvDatabaseName = value;}
}

private string ServerName
{
get{return sServerName;}
set{sServerName = value;}
}
<code>
private int WinNTAuth
{
get{return bUseWinSecurity;}
set{bUseWinSecurity = value;}
}

private int UserAccessLevel
{
get{return iAccessLevel;}
set{iAccessLevel = value;}
}

private string ConnectionString()
{
string connStr = "";
string sMsg = "";
try
{
connStr = "server=" + ServerName + ";" +
"integrated security=SSPI;" +
"database=" + DatabaseName;

}
catch (Exception ex)
{

connStr = "";
sMsg = "DataAccess: ConnectionString: " + ex.Message.ToString();
throw new Exception(sMsg);
}


try
{
if (WinNTAuth == Convert.ToInt16(vbWINNTAuth.vbUseApplication))
{
connStr = connStr + "user id=" + UserName + ";";
connStr = connStr + "PWD=" + Password + ";";
}
else
{
connStr = connStr + "persist security info=True;";
connStr = connStr + "integrated security=sspi;";
}
}
catch (Exception ex)
{
connStr = "";
sMsg = "DataAccess: ConnectionString: " + ex.Message.ToString();
throw new Exception(sMsg);
}

return connStr;

}</code>

private SqlConnection GetConnection()
{
<code>string sMsg = "";
SqlConnection conn = new SqlConnection(ConnectionString());
try</code>
{
conn.Open();
return conn;
}
catch (Exception ex)
{
conn.Close();
if(conn != null)
{
conn = null;
}
sMsg = "DataAccess: GetConnection: " + ex.Message.ToString();
throw new Exception(sMsg);
}
}
public void CloseConnection(SqlConnection conn)
{
string sMsg = "";
try
{
if (conn.State != ConnectionState.Open)
{
conn.Close();
if(conn != null)
{
conn = null;
}
}
}
catch (Exception ex)
{
sMsg = "DataAccess: Login: " + ex.Message.ToString();
throw new Exception(sMsg);
}

}
public bool Login()
{
string sMsg = "";
bool ret = true;
SqlConnection cn = new SqlConnection(ConnectionString());
try
{
cn.Open();

if (cn.State != ConnectionState.Closed)
{
ret = true;
cn.Close();
}
else
{
ret = Convert.ToBoolean(ConnectionState.Closed);
}
}
catch (Exception ex)
{
if (cn.State != ConnectionState.Closed)
{
cn.Close();
if(cn != null)
{
cn = null;
}
}

sMsg = "DataAccess: Login: " + ex.Message.ToString();
throw new Exception(sMsg);
}

return ret;
}
<code></code><code></code></code></code>
AnswerRe: C# And ADO.NET N-Tier Help Pin
Ista13-Dec-05 2:37
Ista13-Dec-05 2:37 
GeneralRe: C# And ADO.NET N-Tier Help Pin
systemnyc13-Dec-05 18:26
systemnyc13-Dec-05 18:26 
GeneralRe: C# And ADO.NET N-Tier Help Pin
Ista14-Dec-05 10:01
Ista14-Dec-05 10:01 
GeneralRe: C# And ADO.NET N-Tier Help Pin
systemnyc14-Dec-05 17:23
systemnyc14-Dec-05 17:23 
Questionusing Authorization Manager and principal permission Pin
keinan12-Dec-05 23:06
keinan12-Dec-05 23:06 
Questionhow to configure log4net for class library project Pin
YogeshChoudhary12-Dec-05 23:03
YogeshChoudhary12-Dec-05 23:03 
AnswerRe: how to configure log4net for class library project Pin
Anthony_Yio13-Dec-05 0:26
Anthony_Yio13-Dec-05 0:26 
GeneralRe: how to configure log4net for class library project Pin
YogeshChoudhary13-Dec-05 0:46
YogeshChoudhary13-Dec-05 0:46 
QuestionCrystal Reprt Pin
albCode12-Dec-05 22:56
albCode12-Dec-05 22:56 
AnswerRe: Crystal Reprt Pin
Polis Pilavas12-Dec-05 23:04
Polis Pilavas12-Dec-05 23:04 
Questionapplication pool getting recycled Pin
savage_12-Dec-05 22:49
savage_12-Dec-05 22:49 
QuestionWhat a character !! Pin
IceWater4212-Dec-05 22:10
IceWater4212-Dec-05 22:10 
AnswerRe: What a character !! Pin
MarcelErz12-Dec-05 22:27
MarcelErz12-Dec-05 22:27 
AnswerRe: What a character !! Pin
Anbuselvan12-Dec-05 22:40
Anbuselvan12-Dec-05 22:40 
AnswerRe: What a character !! Pin
Guffa13-Dec-05 3:27
Guffa13-Dec-05 3:27 
AnswerRe: What a character !! Pin
IceWater4216-Dec-05 6:19
IceWater4216-Dec-05 6:19 
QuestionHow to find the date of day before today ? Pin
Yanshof12-Dec-05 22:03
Yanshof12-Dec-05 22:03 

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.