By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,637 Members | 1,967 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,637 IT Pros & Developers. It's quick & easy.

NVARCHAR and ODBC

P: n/a
Hello All,

I am using ODBC, connecting to an Oracle table that has a column of type
NVARCHAR.

When I try to retrieve data into a string, I don't see it. I imagine its
because the null padding in the data.

Here is some simplified code to show my issue.

// Oracle Table
// CREATE TABLE TableX
// ( EngColumn VARCHAR2(200),
// NLSColumn NVARCHAR2(400));

// EngColumn NLSColumn
// This is some text T h i s i s s o m e
t e x t
// Here is more text H e r e i s m o r e
t e x t

using System.Data;
using System.Data.Odbc;

private void InitializeData()
{
// MyConnection is an OdbcConnection control
OdbcConnection MyConnection = new OdbcConnection();
MyConnection.ConnectionString = = "DSN=" + HostName +
";UID=" + UserName + ";PWD=" + Password + ";";

string Query = "SELECT * FROM TableX";
MyConnection.Open();
OdbcDataAdapter daResults = new OdbcDataAdapter(Query, MyConnection);
MyConnection.Close();

DataTable dtResults = new DataTable();
daResults.Fill(dtResults);
DataGrid1.DataSource = dtResults;
}

private void DataGrid1_CurrentCellChanged(object sender, System.EventArgs e)
{
MessageBox.Show(DataGrid1[DataGrid1.CurrentCell].ToString());
}

If I select a cell in the "EngColumn" I see the data. If I select a cell in
the NLSColumn, I get a blank string. I figure that it is something to do
with Unicode conversion, but I just can't seem to figure it out.

TIA,
pagates
Feb 9 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.