nikolabt 0 Newbie Poster

I have some problem when i try to add new row to the datagrid. On my form i have buttons for Add,Edit,Delete,Save,Cancel how and DataGrid for showing the data. So when i click on the button for adding new data the new row is created in the DataGrid but the problem is after i click on the button the data in the row which was selected is disappear. What wrong i'm doing. The code for adding new row in the DataGrid that i use is

private void btnNovClen_Click(object sender, EventArgs e)
        {
            this.tblDetalnaBindingSource.AddNew();          
        }

so is it this ok or i must do something else.

Pls help me about this problem i'm waiting you answer!!!

nikolabt 0 Newbie Poster

I have MDI application with 3 child forms.One of the child forms i'm using for entering data in Access DB.I have made connection and everything is ok.I'm entering data deleting and all is ok.If i close that child form and open once again the data that was enter on the first opening od that form is here.The problem is when i exit from application and when i start once again and when i open the form for entering data the previous data is not in the DB. What is the problem.All same thing and steps if i do like a just one form not MDI is ok.

Please provide help what is that i must to do on closing the main form or exit!!!

Thanks

nikolabt 0 Newbie Poster

Thanks man a lot for the help i solve the problem!!! :)

I put the new button for Deleting and now is working. Once again thanks for the ideas and for the link!!!

nikolabt 0 Newbie Poster

i have see all poseblle combination and try at. I have add some new data Save and i have check the Access DB open and is ok. Then i have delete the same data open once again the DB and the data was deleted. But another interesting thing that i have saw.For the save button has a Event and the code for that Event is in the Form1.cs.

here is the code that is generated in Form1

namespace testSifraBaza
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void tblDetalnaBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.tblDetalnaBindingSource.EndEdit();
            this.tblDetalnaTableAdapter.Update(this.dsCelosna.tblDetalna);

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dsCelosna.tblDetalna' table. You can move, or remove it, as needed.
            this.tblDetalnaTableAdapter.Fill(this.dsCelosna.tblDetalna);

        }



   
    }
}
nikolabt 0 Newbie Poster

i go to Data Sources window and from there i have crate New Data Source and i have folow the steps. On the end with drag and drop from the Data Source Window i have put on the form and has create a DataGrid View and binding navigator how i have say where has buttons for navigations, for adding new data, deleting and saving. That is i have done and if i have not mentioned i work in Visual C# 2005

Thanks,

nikolabt 0 Newbie Poster

I have try to find the event handler but i can't because the wizard has create own BindingNavigator and put by own Delete button. When i select button and go to events for that button is not showing some event for that button but is working delete data???

How to find?

Thanks,

nikolabt 0 Newbie Poster

I have make connection with the Access DB in Visual C# 2005 everything is ok and working great. The wizard has make and toolbar for adding deleting data and saving.So my question is how i can make now when the user click on let say want to delete data show the confirmation dialog for deleting because now when you click on deleting the data is delete with out asking. I want to do this because some times we can click on some data that we don't want to delete or in mistake we select the data that how i have say don't want to delete.

I'm waiting the answers, pls help.

Thanks

nikolabt 0 Newbie Poster

I have and another question?

How to make when login is sucesiful and will open the page default.aspx to show me for example in textbox or label the first name and second name of the user normaly if in the DB we have information about that.
For example "Welcome John Jonson"

nikolabt 0 Newbie Poster

Thanks a lot Paladine but when i have make like you have write to me and have try something else i always get this error:
'Login1.WebForm1.test(string, string)': not all code paths return a value

the function is:

privatebool test(string txtUser,string txtPassword)
{
OleDbConnection myConn = new OleDbConnection(ConfigurationSettings.AppSettings["strCon"]);
OleDbCommand myCmd = new OleDbCommand("proverka",myConn);
myCmd.CommandType = CommandType.StoredProcedure;
OleDbParameter objParam1,objParam2;
//OleDbParameter returnParam;
objParam1 = myCmd.Parameters.Add("@UserName",OleDbType.Char);
objParam2 = myCmd.Parameters.Add("@Password",OleDbType.Char);
//returnParam = myCmd.Parameters.Add("@ID",OleDbType.Integer);
objParam1.Direction = ParameterDirection.Input;
objParam2.Direction = ParameterDirection.Input;
//returnParam.Direction = ParameterDirection.ReturnValue;
objParam1.Value = txtUser;
objParam2.Value = txtPassword;
 
try
{
if(myConn.State == ConnectionState.Closed)
{
myConn.Open();
//myCmd.ExecuteNonQuery();
}
OleDbDataReader objReader;
objReader = myCmd.ExecuteReader(CommandBehavior.CloseConnection);
while(objReader.Read())
{
if((bool)(objReader.GetValue(0)) == false)
{
Label1.Text="Inavlid Login!";
return false;
}
else
{
objReader.Close();
return true;
}
}
}
catch(Exception ex)
{
Label2.Text = ex + "Error connecting to the DB!";
return false;
}
}
nikolabt 0 Newbie Poster

Hi Paladine! Here is my code i have made in Access my DB and when i compile i get this errorr:
Cannot implicitly convert type 'int' to 'bool'


private bool test(string txtUser,string txtPassword)
{
OleDbConnection myConn = new OleDbConnection(ConfigurationSettings.AppSettings["strCon"]);
OleDbCommand myCmd = new OleDbCommand("proverka",myConn);
myCmd.CommandType = CommandType.StoredProcedure;
OleDbParameter objParam1,objParam2;
//OleDbParameter returnParam;
objParam1 = myCmd.Parameters.Add("@UserName",OleDbType.Char);
objParam2 = myCmd.Parameters.Add("@Password",OleDbType.Char);
//returnParam = myCmd.Parameters.Add("@ID",OleDbType.Integer);
objParam1.Direction = ParameterDirection.Input;
objParam2.Direction = ParameterDirection.Input;
//returnParam.Direction = ParameterDirection.ReturnValue;
objParam1.Value = txtUser;
objParam2.Value = txtPassword;

try
{
if(myConn.State == ConnectionState.Closed)
{
myConn.Open();
//myCmd.ExecuteNonQuery();
}
OleDbDataReader objReader;
objReader = myCmd.ExecuteReader(CommandBehavior.CloseConnection);
while(objReader.Read())
{
if((int)objReader.GetValue(0) = 0) //HERE IS THE ERROR
{
Label1.Text="Inavlid Login!";
return false;
}
else
{
objReader.Close();
return true;
}
}
}
catch(Exception ex)
{
Label2.Text = ex + "Error connecting to the DB!";
return false;
}
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnSubmit.Click += …