How to print the sql statement

Results 1 to 2 of 2

Thread: How to print the sql statement

  1. #1
    Join Date
    Dec 1969

    Default How to print the sql statement

    string strConnection = ConnectionString();<BR> OleDbConnection objConnection = new OleDbConnection(strConnection);<BR> <BR> string strAddEmployeeSQL = "SELECT * FROM OrgEmployee";<BR> DataSet objDataSet = new DataSet();<BR> OleDbDataAdapter objAdapter = new OleDbDataAdapter(strAddEmployeeSQL, objConnection);<BR> objAdapter.Fill(objDataSet, "OrgEmployee");<BR> <BR> DataTable objTable;<BR> DataRow objNewRow;<BR> <BR> objTable = objDataSet.Tables["OrgEmployee"];<BR> objNewRow = objTable.NewRow();<BR> objNewRow["FEID"] = Request.Cookies["PayOut"]["FEID"];<BR> objNewRow["SSN"] = Request.Form["SSN"];<BR> objNewRow["LName"] = Request.Form["LastName"];<BR> objNewRow["FName"] = Request.Form["FirstName"];<BR> objNewRow["MName"] = Request.Form["MiddleName"];<BR><BR> objTable.Rows.Add(objNewRow);<BR> <BR> OleDbCommandBuilder objBuilder = new OleDbCommandBuilder(objAdapter);<BR> objAdapter.UpdateCommand = objBuilder.GetUpdateCommand();<BR> objAdapter.InsertCommand = objBuilder.GetInsertCommand();<BR> objAdapter.DeleteCommand = objBuilder.GetDeleteCommand();<BR> objAdapter.Update(objDataSet, "OrgEmployee");<BR><BR>I am getting an error saying there is something wrong with my INSERT statement. How can I print the SQL statement? thanks

  2. #2
    Join Date
    Dec 1969

    Default RE: How to print the sql statement

    Try to write the value of: <BR>objBuilder.GetInsertCommand();<BR><BR>From the MSDN:<BR>"An application can use the GetInsertCommand method for informational or troubleshooting purposes because it returns the text of the OleDbCommand object to be executed."<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts