Click here to Skip to main content
15,919,613 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
so i want to make software for sell so to search from datagridview cell product and then add in all cells and then one button save and also option for modified from invoice id if i modife datagridview so one button and all will be save like insert delete or update in datagridview

i have try option it work but i get problem with insert new row so i get error becouse i need to add also invoice id in database and UserADD Becouse cant to be Null
so i want invoice id and UserADD to take from textbox

"Cannot insert the value NULL into column 'UserADD', table 'DBDash.dbo.ddo'; column does not allow nulls. INSERT fails"

What I have tried:

C#
SqlDataAdapter AdapterNow;
        DataSet DataNow = new DataSet();
        SqlCommand cmd;

        private void GetData()
        {
            string invoiceID = TextBox1.Text;
            con.Open();
            cmd = con.Testiiiii(invoiceID);

            AdapterNow = new SqlDataAdapter(cmd);
            DataNow.Clear();
            AdapterNow.Fill(DataNow);
            dataGridView1.DataSource = DataNow.Tables[0];
            con.Close();
        }

        private void Update111()
        {
            SqlCommandBuilder cmd = new SqlCommandBuilder(AdapterNow);
            DataSet changes = new DataSet();
            changes = DataNow.GetChanges();
            if (changes != null)
            {
                AdapterNow.Update(changes);
                AdapterNow.Fill(DataNow);
                dataGridView1.DataSource = DataNow.Tables[0];
                GetData();
            }
        }
Posted
Updated 23-Feb-22 13:52pm
v9
Comments
OriginalGriff 23-Feb-22 2:08am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with - we get no other context for your project.
Imagine this: you go for a drive in the country, but you have a problem with the car. You call the garage, say "it broke" and turn off your phone. How long will you be waiting before the garage arrives with the right bits and tools to fix the car given they don't know what make or model it is, who you are, what happened when it all went wrong, or even where you are?

That's what you've done here. So stop typing as little as possible and try explaining things to people who have no way to access your project!

Use the "Improve question" widget to edit your question and provide better information.
Member 14813076 23-Feb-22 5:41am    
Done Meybe Help me now sorry for mi englisht

1 solution

Your function Testiiiii is expecting two parameters - which you are not using at all in the function
C#
public SqlCommand Testiiiii(string Org, string Dok)
Yet you call it with only one
C#
cmd = con.Testiiiii(textBox2.Text);
I will assume that textBox2 contains the invoice id. First thing you should do is rename that text box to a meaningful name e.g. InvoiceId

Next change your function declaration e.g.
C#
public SqlCommand Testiiiii(string invoiceID)
Then it should start working
 
Share this answer
 
Comments
Member 14813076 23-Feb-22 6:28am    
no its not problem there it just show data in datagridview its just explain in mi code its fixed it so it work to show data i have another problem with insert row in datagridview
"Cannot insert the value NULL into column 'UserADD', table 'DBDash.dbo.ddo'; column does not allow nulls. INSERT fails" so i need to add also useradd and invoiceID but this two are not in datagridview row so i want to make this two from textbox to put sql check private void Update111()

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900