problem about sqldatareader-Collection of common programming errors


  • aliasbody
    c# sql-server class sqldatareader
    I have a problem with C#, I have a Class with a function for SqlDataReader and another for SqlCommand (the first one is just for read values from a DataBase and the second one is for INSERT, UPDATE, DELETE … in the same DB).The problem is, for the first part of the code (the login), I have to search the values from an Active Directory (it works), then I must see if the user has username and password in my own DB (it works), and then, if the user is not in the DB then I have to create it and ge

  • Paul
    sql-server ado.net sqldatareader
    So I’m running a query in ADO.NET that I know returns a single row. The relevant portion of my code looks like:SqlCommand sqc = new SqlCommand(); sqc.Connection = new SqlConnection(“connection string”); sqc.CommandText = “SELECT A, B FROM C WHERE D=@d”; sqc.Parameters.AddWithValue(“@d”, “d”); sqc.Connection.Open(); SqlDataReader rdr = sqc.ExecuteReader(); bool boolio = rdr.Read(); String a = (String)rdr[“A”];When I run this, I get an exception on the final line, complaining that I’m trying to re

  • Soner Gönül
    c# asp.net database delete sqldatareader
    I hava a table AVUKAT Columns–> HESAP, MUSTERI, AVUKATThis is my delete button codeprotected void Delete_Click(object sender, EventArgs e){string strConnectionString = ConfigurationManager.ConnectionStrings[“SqlServerCstr”].ConnectionString;SqlConnection myConnection = new SqlConnection(strConnectionString);myConnection.Open();string hesap = Label1.Text;string musteriadi = DropDownList1.SelectedItem.Value;string avukat = DropDownList2.SelectedItem.Value;SqlCommand cmd = new SqlCommand(“DELETE F

  • Renan
    asp.net c#-4.0 sqldatareader
    I’ve been away from programming for a while but recently I’ve got a need for it.I have a problem with SQL DataReader using Sql Server Compact Edition 4.0 (VS2012 Built-in).string connstring = “Data Source=C:\\..(Path Here)..\\VacationsDB.sdf”; SqlCeConnection conn = new SqlCeConnection(connstring); string strSQL = “SELECT * FROM Vacation WHERE VacationNo = @val”;using (SqlCeCommand cmd = new SqlCeCommand(strSQL, conn)) {//read search value from from text fieldcmd.Parameters.AddWithValue(“@val”,

  • Otiel
    c# stored-procedures ado.net autocomplete sqldatareader
    I am trying to have a textBox auto complete with values from a database. When i bullet test the code will walk though until the if statement in the function below. Could some one please tell me why my code wont execute after that if?I am trying to run the following but it keeps jumping out before the if:public AutoCompleteStringCollection AutoCompleate(string dataBase, string procedure) {AutoCompleteStringCollection namesCollection =new AutoCompleteStringCollection();SqlDataReader dReader;SqlCom

  • Brice
    c# integer int sqldatareader
    I am confused by the following issue;I am trying to retrieve a record (column ‘EmployeeId’ (int)) using a SqlDataReader.When I run the query directly on the server, I got the record correctly. When I run the same procedure to get another column (string) I got the record correctly.I assume the issue is due to the fact that I try to get an int, the program skips the while (mySqlDbDataReader.Read())and goes directly to catch (Exception eMsg1){Here is the full procedurepublic string getUser