本文整理汇总了C#中Connection.Disconnect方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.Disconnect方法的具体用法?C# Connection.Disconnect怎么用?C# Connection.Disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection.Disconnect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: buttonSubmit_Click
private void buttonSubmit_Click(object sender, EventArgs e)
{
using (Connection conn = new Connection("myConn"))
{
conn.Connect(textBoxServer.Text);
conn.LogOn(textBoxUsername.Text, textBoxPassword.Text);
DBObject dbObj = null;
try
{
int id = Convert.ToInt32(textBoxID.Text);
dbObj = conn.GetObject(new ObjectId(id));
if (dbObj == null) throw new Exception("Invalid object ID.");
if (!dbObj.IsGroup) throw new Exception("Object is not a group.");
}
catch (FormatException ex)
{
MessageBox.Show("Enter a valid object ID.");
return;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
if (dbObj.ClassDefinition.Name == "CTemplateInstance") ProcessInstance(dbObj);
else if (dbObj.ClassDefinition.Name == "CTemplate") ProcessTemplate(dbObj);
conn.LogOff();
conn.Disconnect();
}
}
示例2: Right
public static void Right()
{
Connection connection = new Connection();
connection.ConnectionString = "DataSource=//MyMachine";
connection.Connect();
connection.Disconnect();
}
示例3: Wrong1
public static void Wrong1()
{
Connection connection = new Connection();
connection.Connect();
connection.Disconnect();
}
示例4: ReadHeader
public Boolean ReadHeader(Connection connection)
{
this.fFirstHeader = String.Empty;
String lStart = HttpHeaders.ReadHttpMethodName(connection);
if (lStart == null)
return false;
if (String.Equals(lStart, String.Empty, StringComparison.Ordinal))
throw new HttpRequestInvalidException(500, "Invalid HTTP Request, 'POST', 'MERGE', 'GET', 'DELETE', 'PUT' or 'HEAD' header expected.");
String lHeaderLine;
do
{
lHeaderLine = connection.ReadLine();
if (!String.IsNullOrEmpty(lHeaderLine))
{
if (this.fFirstHeader.Length == 0)
{
this.fFirstHeader = lStart + lHeaderLine;
}
else
{
Int32 lPos = lHeaderLine.IndexOf(":");
if (lPos == -1)
throw new HttpHeaderException("Invalid HTTP Header Line \"" + lHeaderLine + "\"");
String lName = lHeaderLine.Substring(0, lPos);
String lValue = null;
// There should be a space after the ":" , but at least one custome said that this is not
// always true
// So we check if there is space after the ":"
if (lHeaderLine.Length > lPos + 1)
{
if (lHeaderLine[lPos + 1] == ' ')
lValue = lHeaderLine.Substring(lPos + 2);
else
lValue = lHeaderLine.Substring(lPos + 1);
}
HttpHeader lHeader = this[lName];
if (lHeader == null)
{
lHeader = new HttpHeader(lName, lValue);
fHeaders.Add(lName, lHeader);
}
else
{
lHeader.Add(lValue);
}
}
}
if (this.MaxHeaderLinesEnabled && this.fHeaders.Count > this.MaxHeaderLines - 1) // -1 because FirstHeader is not in hashtable
{
connection.Disconnect();
throw new HttpHeaderException(String.Format("Too many header lines received (maximum is set to {0})", MaxHeaderLines));
}
}
while (!String.IsNullOrEmpty(lHeaderLine));
this.ParseFirstLine();
return true;
}