本文整理汇总了C#中System.Data.OleDb.OleDbDataReader.Close方法的典型用法代码示例。如果您正苦于以下问题:C# OleDbDataReader.Close方法的具体用法?C# OleDbDataReader.Close怎么用?C# OleDbDataReader.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.OleDb.OleDbDataReader
的用法示例。
在下文中一共展示了OleDbDataReader.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Button2_Click
protected void Button2_Click(object sender, EventArgs e)
{
string s_add, r_add, message, heading,muid;
s_add = Session["us_name"].ToString();
r_add = TextBox1.Text;
heading = TextBox3.Text;
message = TextBox2.Text;
rec_mail te = new rec_mail();
conn = new OleDbConnection("Provider=MSDAORA;Data Source=orcl;Persist Security Info=True;Password=db_mail;User ID=db_mail");
conn.Open();
cmd = new OleDbCommand("insert into messages values(m_id.nextval,'" + heading + "','" + message + "'," + file_name + "',sysdate,sysdate,'Draft')", conn);
dr = cmd.ExecuteReader();
cmd = new OleDbCommand("insert into mail_exchange values('" + s_add + "',m_id.currval,sysdate,sysdate,'" + r_add + "')", conn);
dr = cmd.ExecuteReader();
cmd = new OleDbCommand("insert into draft values(m_id.currval)", conn);
dr = cmd.ExecuteReader();
dr.Close();
cmd = new OleDbCommand("select m_id.currval from dual", conn);
dr = cmd.ExecuteReader();
dr.Read();
muid = dr[0].ToString();
dr.Close();
conn.Close();
Label1.Text = "Message Saved. Your message id is " + muid;
Label1.Visible = true;
dr.Close();
conn.Close();
}
示例2: addGame
public void addGame(Game obj, int num)
{
try
{
database = new OleDbConnection(connectionString);
database.Open();
string queryString = "INSERT INTO Game (Title, Description, Publisher, ReleaseDate, Rating, PurchasePrice, Copies) " +
"VALUES ('" + obj.Title + "', '" + obj.Description + "', '" + obj.Publisher + "', '" + obj.ReleaseDate + "', '" +
obj.Rating + "', '" + obj.Price + "', '" + obj.Copies + "')";
string queryString2 = "SELECT * FROM Game WHERE Title = '" + obj.Title + "'";
string queryString3;
OleDbCommand cmd = new OleDbCommand(queryString, database);
OleDbCommand cmd2 = new OleDbCommand(queryString2, database);
count = cmd.ExecuteNonQuery();
reader = cmd2.ExecuteReader();
Game temp = new Game();
reader.Read();
temp.Id = Int32.Parse(reader["ID"].ToString());
temp.Title = reader["Title"].ToString();
temp.Description = reader["Description"].ToString();
temp.Publisher = reader["Publisher"].ToString();
temp.ReleaseDate = reader["ReleaseDate"].ToString();
temp.Rating = reader["Rating"].ToString();
temp.Price = Double.Parse(reader["PurchasePrice"].ToString());
temp.Copies = Int32.Parse(reader["Copies"].ToString());
queryString3 = "INSERT INTO GameCopy (CheckedOut, GameID) " +
"VALUES (false, '" + temp.Id + "')";
OleDbCommand cmd3 = new OleDbCommand(queryString3, database);
for (int i = 0; i < num; i++)
count2 = cmd3.ExecuteNonQuery();
if (count >= 1)
MessageBox.Show(obj.Title + " has been added!");
else
MessageBox.Show("Error: Could not add game!");
reader.Close();
database.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
reader.Close();
database.Close();
}
}
示例3: gen_btn_Click
private void gen_btn_Click(object sender, EventArgs e)
{
string department = comboBox1.Text;
sqlQuery = "SELECT * FROM EMPLOYEES WHERE DEPARTMENT LIKE '" + department + "' ORDER BY last_name asc";
cmd.CommandText = sqlQuery;
cmd.Connection = cn;
dr = cmd.ExecuteReader();
using (StreamWriter sw = new StreamWriter("C:/Users/Developer/Desktop/itpl project/itplProject/payrolls/payroll_"+ department +"_"+ DateTime.Now.ToString("mm-dd-yy")+".txt"))
{
sw.WriteLine("Report Generated at : " + DateTime.Now);
sw.WriteLine(" Department, Last Name, First Name, Salary");
sw.WriteLine("---------------------------------");
while (dr.Read())
{
sw.Write(dr["department"].ToString());
sw.Write(", "+ dr["last_name"].ToString());
sw.Write(", " + dr["first_name"].ToString());
sw.Write(", " + dr["salary"].ToString());
sw.WriteLine();
}
sw.WriteLine("---------------------------------");
sw.Close();
dr.Close();
this.Close();
MessageBox.Show("Check your File Directory!");
}
}
示例4: PopulaTela
public void PopulaTela()
{
rsListar = objBD.ExecutaSQL("EXEC site_psCriacaoDocumentadasPorID '" + Request["CDO_ID"] + "' ");
if (rsListar == null)
{
throw new Exception();
}
if (rsListar.HasRows)
{
rsListar.Read();
CDO_ID.Attributes.Add("value", Request["CDO_ID"].ToString());
titu_criacoes.InnerHtml = objUtils.RemoveHTML(rsListar["CDO_TAREFA"].ToString());
criador.InnerHtml = rsListar["ADM_NOME"].ToString();
data.InnerHtml = rsListar["CDO_DATA"].ToString();
box_descritivo.InnerHtml = rsListar["CDO_DESCRITIVO"].ToString();
video_criacoes.Attributes.Add("src", "https://www.youtube.com/embed/" + rsListar["CDO_VIDEO"].ToString());
// aRelato.Attributes.Add("href", "/enviar-relato.aspx?CDO_ID=" + Request["CDO_ID"] + "");
relato_detalhe.InnerHtml = "<strong>" + rsListar["TOTAL_RELATOS"].ToString() + " Relatos Enviados</strong>";
totalComentarios.InnerHtml = rsListar["TOTAL_COMENTARIOS"].ToString() + " Comentário";
if (Convert.ToInt16(rsListar["TOTAL_COMENTARIOS"]) > 1)
{
totalComentarios.InnerHtml += "s";
}
}
else
{
Response.Redirect("/criacoes-documentadas");
}
rsListar.Close();
rsListar.Dispose();
}
示例5: PopularBlog
public void PopularBlog(int RED_ID)
{
rsBlog = objBD.ExecutaSQL("EXEC site_psPostBlog " + RED_ID + " ");
if (rsBlog == null)
{
throw new Exception();
}
if (rsBlog.HasRows)
{
while (rsBlog.Read())
{
ulPost.InnerHtml += " <li><a href=\"/post/" + objUtils.GerarURLAmigavel(rsBlog["POS_TITULO"].ToString()) + "\" title=\"Titulo da postagem\">";
if (string.IsNullOrWhiteSpace(rsBlog["POS_IMAGEM"].ToString()) == false)
{
ulPost.InnerHtml += " <img src='/upload/imagens/blog/thumb-" + rsBlog["POS_IMAGEM"].ToString() + "'>";
}
else
{
ulPost.InnerHtml += " <img src='images/img-post-blog-padrao.png'>";
}
ulPost.InnerHtml += " </a>";
ulPost.InnerHtml += " <p class=\"titu_post_home\"><a href=\"post/" + objUtils.GerarURLAmigavel(rsBlog["POS_TITULO"].ToString()) + "\">" + objUtils.CortarString(true, 36, rsBlog["POS_TITULO"].ToString()) + "</a></p>";
ulPost.InnerHtml += " <p class=\"desc_post_home\"><a href=\"post/" + objUtils.GerarURLAmigavel(rsBlog["POS_TITULO"].ToString()) + "\">" + objUtils.RemoveHTML(objUtils.CortarString(true, 110, rsBlog["POS_TEXTO"].ToString())) + "</a></p>";
//ulPost.InnerHtml += " <p class=\"desc_post_home\"> </p>";
ulPost.InnerHtml += " <a href=\"/post/" + objUtils.GerarURLAmigavel(rsBlog["POS_TITULO"].ToString()) + "\" class=\"btn\">LEIA MAIS</a>";
ulPost.InnerHtml += " </li>";
}
}
rsBlog.Dispose();
rsBlog.Close();
}
示例6: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
string raw,s_add, message, heading,muid;
string[] r_add = new string[100];
int i;
s_add = Session["us_name"].ToString();
raw = TextBox1.Text;
heading = TextBox3.Text;
message = TextBox2.Text;
r_add=raw.Split(',');
rec_mail te = new rec_mail();
conn = new OleDbConnection("Provider=MSDAORA;Data Source=orcl;Persist Security Info=True;Password=db_mail;User ID=db_mail");
conn.Open();
if (file_name == null)
file_name = "NA";
cmd = new OleDbCommand("insert into messages values(m_id.nextval,'" + heading + "','" + message + "','" + file_name + "',sysdate,sysdate,'delivered')", conn);
dr = cmd.ExecuteReader();
dr.Close();
for (i = 0; i < r_add.Length; i++)
{
cmd = new OleDbCommand("insert into mail_exchange values('" + s_add + "',m_id.currval,sysdate,sysdate,'" + r_add[i].ToString() + "')", conn);
dr = cmd.ExecuteReader();
}
dr.Close();
cmd = new OleDbCommand("select m_id.currval from dual", conn);
dr = cmd.ExecuteReader();
dr.Read();
muid=dr[0].ToString();
dr.Close();
conn.Close();
Label1.Text = "Message Sent. Your message id is " +muid;
Label1.Visible = true;
}
示例7: AlterarDados
public void AlterarDados(tbVendaDTO venda)
{
String sSQL = "";
sSQL += "UPDATE tbVenda SET idProduto = @idProduto, idVendedor = @idVendedor, qtQuantidade = @qtQuantidade WHERE idVenda = @idVenda ";
conexao = (OleDbConnection)CriaConexaoOleDb();
command = new OleDbCommand(sSQL, conexao);
command.CommandType = CommandType.Text;
OleDbParameter parametro = command.Parameters.Add("@idProduto", OleDbType.Integer);
parametro.Value = venda.Produto.idProduto;
parametro = command.Parameters.Add("@idVendedor", OleDbType.Integer);
parametro.Value = venda.Vendedor.idVendedor;
parametro = command.Parameters.Add("@qtQuantidade", OleDbType.Integer);
parametro.Value = venda.qtQuantidade;
parametro = command.Parameters.Add("@idVenda", OleDbType.Integer);
parametro.Value = venda.idVenda;
try
{
drOleDb = command.ExecuteReader();
drOleDb.Close();
conexao.Close();
}
catch (SystemException e)
{
erro = e.Message;
}
}
示例8: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
mySelectCommand.CommandType = CommandType.Text;
mySelectCommand.CommandText = "SELECT Name, FoodTypeID FROM FoodType ORDER BY Name DESC";
myReader = mySelectCommand.ExecuteReader();
bool notEoF;
//read first row from database
notEoF = myReader.Read();
//read row by row until the last row
if (ddlCategory.Items.Count == 0)
{
ddlCategory.Items.Add("All Categories");
while (notEoF)
{
ddlCategory.Items.Add(myReader["Name"].ToString());
ddlCategory.Items[ddlCategory.Items.Count - 1].Value = myReader["FoodTypeID"].ToString();
notEoF = myReader.Read();
}
}
myReader.Close();
if(!Page.IsPostBack)
{
getDB();
}
}
示例9: Initialise
public void Initialise()
{
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=phonebook.accdb";
OleDbConnection conn = new OleDbConnection(connectionString);
string sql = "SELECT * FROM task ORDER BY id";
OleDbCommand cmd = new OleDbCommand(sql, conn);
try
{
conn.Open();
reader = cmd.ExecuteReader();
reader.Read();
lblTask.Text = reader.GetString(1).ToString();
txtTask.Text = reader.GetString(2).ToString();
reader.Close();
conn.Close();
}
catch
{
//MessageBox.Show(e.Message);
}
}
示例10: Ultimas
public void Ultimas()
{
rsLista = objBD.ExecutaSQL("select top 3 F.FTO_ID, U.USU_NOME, U.USU_USUARIO, FME_MENSAGEM, CONVERT(VARCHAR(10),FME_DH_PUBLICACAO, 103) AS FME_DH_PUBLICACAO, T.FTO_TITULO from ForumMensagem F inner join ForumTopicos T on (T.FTO_ID = F.FTO_ID) inner join Usuario U ON (U.USU_ID = F.USU_ID) where RED_ID = " + Session["redeID"] + " and F.FME_ATIVO = 1 order by F.FME_DH_PUBLICACAO desc");
if (rsLista == null)
{
throw new Exception();
}
if (rsLista.HasRows)
{
while (rsLista.Read())
{
ultimasMensagens.InnerHtml += " <div class=\"txt blog_txt txt_forum\">";
ultimasMensagens.InnerHtml += " <div class=\"txt\">";
ultimasMensagens.InnerHtml += " <a href=\"/forum-lista/" + objUtils.GerarURLAmigavel(rsLista["FTO_TITULO"].ToString()) + "/1\" title=\"" + rsLista["FTO_TITULO"] + "\"><p>" + objUtils.CortarString(true, 100, rsLista["FME_MENSAGEM"].ToString()) + "</p></a>";
ultimasMensagens.InnerHtml += " <p class=\"destque_forum\">Mensagem enviada por: <a href='/perfil/" + rsLista["USU_USUARIO"].ToString() + "' title='" + rsLista["USU_NOME"].ToString() + "'>" + rsLista["USU_NOME"].ToString() + "</a></p>";
ultimasMensagens.InnerHtml += " <p class=\"destque_forum\">Enviada em: <b>" + rsLista["FME_DH_PUBLICACAO"].ToString() + "</b></p>";
ultimasMensagens.InnerHtml += " <p class=\"destque_forum\">Tópico: <b><a href=\"/forum-lista/" + objUtils.GerarURLAmigavel(rsLista["FTO_TITULO"].ToString()) + "/1\" title=\"" + rsLista["FTO_TITULO"] + "\">" + rsLista["FTO_TITULO"].ToString() + "</a></b></p><br /><br />";
ultimasMensagens.InnerHtml += " </div>";
ultimasMensagens.InnerHtml += " </div>";
}
}
rsLista.Close();
rsLista.Dispose();
}
示例11: AlterarDados
public void AlterarDados(tbVendedorDTO vendedor)
{
String sSQL = "";
sSQL += "UPDATE tbVendedor SET dsNome = @dsNome, dtNascimento = @dtNascimento WHERE idVendedor = @idVendedor ";
conexao = (OleDbConnection)CriaConexaoOleDb();
command = new OleDbCommand(sSQL, conexao);
command.CommandType = CommandType.Text;
OleDbParameter parametro = command.Parameters.Add("@dsNome", OleDbType.VarChar);
parametro.Value = vendedor.dsNome;
parametro = command.Parameters.Add("@dtNascimento", OleDbType.Date);
parametro.Value = vendedor.dtNascimento;
parametro = command.Parameters.Add("@idVendedor", OleDbType.Integer);
parametro.Value = vendedor.idVendedor;
try
{
drOleDb = command.ExecuteReader();
drOleDb.Close();
conexao.Close();
}
catch (SystemException e)
{
erro = e.Message;
}
}
示例12: LoadById
public static string LoadById(int id)
{
string sql = "SELECT * FROM CUSTOMER WHERE CUSTID = " + id.ToString() + "";
string name = "";
try
{
cn = new OleDbConnection(path);
cn.Open();
cmd.Connection = cn;
cmd.CommandText = sql;
cmd.CommandType = CommandType.TableDirect;
dr = cmd.ExecuteReader();
dr.Read();
name = dr[1].ToString();
}
catch (Exception e)
{
}
finally
{
if (dr != null && !dr.IsClosed)
{
dr.Close();
}
cmd.Dispose();
cn.Close();
}
return name;
}
示例13: photos
//Get all pictures from Database and save in a list
public List<byte[]> photos()
{
byte[] aBytes = null;
List<byte[]> pictures = new List<byte[]> {};
for (int i = 1; i <= 5000; i++)
{
try
{
int cont = 0;
string query = "SELECT image FROM Data WHERE counter = " + i + " AND image <> NULL;";
command = new OleDbCommand(query, connection);
reader = command.ExecuteReader();
while (reader.Read())
{
aBytes = (byte[])reader.GetValue(cont);
pictures.Add(aBytes);
cont++;
}
reader.Close();
}
catch (Exception e)
{
////The error message is not displayed to continue with the process.
//MessageBox.Show("I'm so sorry, we cannot get the images.\n" + e);
}
}
return pictures;
}
示例14: populaLista
public void populaLista()
{
rsPlay = objBD.ExecutaSQL("select PLI_ID, PLI_TITULO, PLI_URL from PlayList where PLI_ATIVO = 1 order by PLI_DH_CADASTRO desc");
if (rsPlay == null)
{
throw new Exception();
}
if (rsPlay.HasRows)
{
while (rsPlay.Read())
{
if (aux == 1)
{
objVideo.InnerHtml += "<iframe width=\"480\" height=\"269\" src=\""+rsPlay["PLI_URL"].ToString()+"\" frameborder=\"0\" allowfullscreen></iframe>";
}
System.Web.UI.WebControls.ListItem R = new System.Web.UI.WebControls.ListItem();
R.Value = rsPlay["PLI_ID"].ToString();
R.Text = rsPlay["PLI_TITULO"].ToString();
slPlayList.Items.Add(R);
aux++;
}
}
rsPlay.Close();
rsPlay.Dispose();
}
示例15: mudarGaleria
public void mudarGaleria(int id)
{
rsGaleria = objBD.ExecutaSQL("select AFO_ID, AFO_TITULO, AFO_KEY from AlbumFotos where AFO_ID = "+id+" order by AFO_DH_CADASTRO desc");
if (rsGaleria == null)
{
throw new Exception();
}
if (rsGaleria.HasRows)
{
rsGaleria.Read();
retorno += "<object width=\"468\" height=\"297\">";
retorno += " <param name=\"flashvars\" value=\"offsite=true&lang=en-us&page_show_url=%2Fphotos%2Fbrincamusicais%2Fsets%2F" + rsGaleria["AFO_KEY"] + "%2Fshow%2F&page_show_back_url=%2Fphotos%2Fbrincamusicais%2Fsets%2F" + rsGaleria["AFO_KEY"] + "%2F&set_id=" + rsGaleria["AFO_KEY"] + "&jump_to=\"></param>";
retorno += " <param name=\"movie\" value=\"https://www.flickr.com/apps/slideshow/show.swf?v=1811922554\"></param>";
retorno += " <param name=\"allowFullScreen\" value=\"true\"></param>";
retorno += " <embed type=\"application/x-shockwave-flash\" src=\"https://www.flickr.com/apps/slideshow/show.swf?v=1811922554\" allowfullscreen=\"true\" flashvars=\"offsite=true&lang=en-us&page_show_url=%2Fphotos%2Fbrincamusicais%2Fsets%2F" + rsGaleria["AFO_KEY"] + "%2Fshow%2F&page_show_back_url=%2Fphotos%2Fbrincamusicais%2Fsets%2F" + rsGaleria["AFO_KEY"] + "%2F&set_id=" + rsGaleria["AFO_KEY"] + "&jump_to=\" width=\"468\" height=\"297\"></embed>";
retorno += "</object>";
retorno += "|";
retorno += ""+id+"";
retorno += "|";
}
Response.Write(retorno);
rsGaleria.Close();
rsGaleria.Dispose();
}