0

Hi,

In asp.net I am using ODBC connection with dsn. I have some experience on VB6. In VB we used to append records in database with command;

connection.addnew

databasefieldname=somvalue

connection.update

my query is - can we do something like this in asp.net?


Alok

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by dnanetwork
0

Not quite that easily but yes you can. You can specify an update query to run but how you formulate that query depends on the ODBC driver you are using. What type of database is it?

Here is a sample of how to interface with ODBC in .NET

private void button3_Click(object sender, EventArgs e)
    {
      DataTable result = default(DataTable); //if you're returning values
      try
      {
        using (System.Data.Odbc.OdbcConnection conn = new System.Data.Odbc.OdbcConnection("DSN=..."))
        {
          conn.Open();
          const string query = "Update Table Set Field = 'Value'";
          using (System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand(query, conn))
          {
            using (System.Data.Odbc.OdbcDataReader dr = cmd.ExecuteReader())
            {
              result = new DataTable();
              result.Load(dr);
            }
          }
        }
      }
      finally
      {
        if (result != null)
          result.Dispose();
      }
    }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.