hello all,
I need assistance on MS Access 2007 database with C#, I have a form with many textboxes.. and i need to store these userfilled data to my database! and after that I need to see detail of any perticular item form database!!! please say how to do this...

Recommended Answers

[QUOTE=finito;1220962]Well The Insert Statement in SQL would look like

Insert INTO TABLE1 (FIRST_NAME) VALUES ('" + textbox2.text + "')

did you connect your database and fill your dataset?[/QUOTE]

You should always use parameterized queries. An example of parameters with OleDb:
[code]
private void buttonUpload_Click(object sender, EventArgs e)
{
using …

Jump to Post

All 12 Replies

Re: MSAccess2007 database in VC#.NET with ADO.NET 80 80

bausahab what you are asking for is the main functionality.

Hmm Can you show what you have done so far?

Re: MSAccess2007 database in VC#.NET with ADO.NET 80 80

just created a Form with textboxes and a access database.. and created query.
now want to save Form data to data base.. please give an illustrative coding for this problem..

Re: MSAccess2007 database in VC#.NET with ADO.NET 80 80

. please give an illustrative coding for this problem..

not sure what you mean.

How well versed are you in SQL? how much do you know about Datasets?

just created a Form with textboxes and a access database..

I am assuming they are not connected to each other?

Please read the following:

http://www.connectionstrings.com/access-2007
http://msdn.microsoft.com/en-us/library/8bw9ksd6%28VS.71%29.aspx
http://sqlzoo.net/

have a good read and ask specific questions.

Re: MSAccess2007 database in VC#.NET with ADO.NET 80 80

oops! I connected database to my project already..and " conn.open();" just need how to add data in database with Form's textboxes.? for the present I am seeing your given links..and thanks for being online

Re: MSAccess2007 database in VC#.NET with ADO.NET 80 80

ok let me know when you have a question, I will be on for another hour or so.

Re: MSAccess2007 database in VC#.NET with ADO.NET 80 80

well .. I have one .. what code shoul I write for the inserting data into database.?
while I am adding string into " textbox2.text" and wnat to save it to database's TABLE 1> FIRST_NAME.. is it someting clear?:S

Re: MSAccess2007 database in VC#.NET with ADO.NET 80 80

Well The Insert Statement in SQL would look like

Insert INTO TABLE1 (FIRST_NAME) VALUES ('" + textbox2.text + "')

did you connect your database and fill your dataset?

Re: MSAccess2007 database in VC#.NET with ADO.NET 80 80

Well The Insert Statement in SQL would look like

Insert INTO TABLE1 (FIRST_NAME) VALUES ('" + textbox2.text + "')

did you connect your database and fill your dataset?

You should always use parameterized queries. An example of parameters with OleDb:

private void buttonUpload_Click(object sender, EventArgs e)
    {
      using (OleDbConnection conn = new OleDbConnection(connStr))
      {
        conn.Open();
        using (OleDbCommand cmd = new OleDbCommand("Insert Into IMG (IMG) Values (?)", conn))
        {
          cmd.Parameters.Add(new OleDbParameter("@IMG", OleDbType.Binary)).Value = System.IO.File.ReadAllBytes(@"C:\picture2.bmp");
          cmd.ExecuteNonQuery();
        }
        conn.Close();
      }
    }

It is very similar when using ODBC or SQL data access objects as well.

Re: MSAccess2007 database in VC#.NET with ADO.NET 80 80

I have many textboxes for to submit details of a student and I need to add these details to database(MS access).. how can I do this .. can you Please write any illustrative code for this task?? I maked database as equal fields in my form's textboxes are.... and connect this database to my project.. with adapter and dataset.. now the INSERing data is remaining.. Please solve.

Re: MSAccess2007 database in VC#.NET with ADO.NET 80 80

Like Sknake said

using (OleDbCommand cmd = new OleDbCommand("Insert Into IMG (IMG) Values (?)", conn))

now Just Add a comma

public static OleDbDataAdapter CreateCustomerAdapter(OleDbConnection conn)
{
  OleDbDataAdapter da = new OleDbDataAdapter();
  OleDbCommand cmd;

  // Create the SelectCommand.

  cmd = new OleDbCommand("SELECT * FROM Customers " +
                       "WHERE Country = @Country AND City = @City", conn);

  cmd.Parameters.Add("@Country", OleDbType.VarChar, 15);
  cmd.Parameters.Add("@City", OleDbType.VarChar, 15);

  da.SelectCommand = cmd;

  // Create the InsertCommand.

  cmd = new OleDbCommand("INSERT INTO Customers (CustomerID, CompanyName) " +
                       "VALUES (@CustomerID, @CompanyName)", conn);

  cmd.Parameters.Add("@CustomerID", OleDbType.Char, 5, "CustomerID"); // Here "CustomerID" would be textBox1.text
  cmd.Parameters.Add("@CompanyName", OleDbType.VarChar, 40, "CompanyName"); //Here "CustomerName" would be textBox2.text and so on

  da.InsertCommand = cmd;

  return da;

http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbdataadapter.insertcommand%28VS.71%29.aspx

Re: MSAccess2007 database in VC#.NET with ADO.NET 80 80

ok I am trying... and will say you..

Re: MSAccess2007 database in VC#.NET with ADO.NET 80 80

did this work for you? please mark as solved...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.