Question problem with data accessing with nchar datatype

krishna2010

New member
Joined
Jul 24, 2010
Messages
2
Programming Experience
Beginner
hi frnds,

Please help me in this query,my code looks as below,
when i click save button data is saved succefully in oracle datbase with '???',when i click get button also the text is coming with '???' in my textbox.
my question is how can i get the same font data into my textbox.please help me asap.

note:my textbox data is in 'Gautami font' such as indian lanuage 'telugu'.
VB.NET:
Imports System.Data
Imports System.Data.OleDb
Public Class Form2
    Dim con As New OleDbConnection("provider=msdaora.1;user id=scott;password=tiger")
    Dim cmd As New OleDbCommand
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cmd.Connection = con
    End Sub

    Private Sub save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        cmd.CommandText = "insert into tel values(N'" & TextBox1.Text & "',N'" & TextBox2.Text & "')"
        con.Open()
        cmd.ExecuteNonQuery()
        con.Close()
        MsgBox("Record saved successfully")

    End Sub

    Private Sub get_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        cmd.CommandText = "select fname from tel"
        con.Open()
        TextBox1.Text = cmd.ExecuteScalar
        con.Close()
    End Sub
End Class
Thanks
in advance.
 
Last edited by a moderator:
First up, the .NET Framework includes an Oracle-specific ADO.NET provider (although it has been deprecated) and Oracle provide one as a free download, so I'd suggest that you use one of those in preference to OleDb.

Secondly, you should never use string concatenation to insert values into SQL code. You should always use parameters. For more information, follow the Blog link in my signature and check out my post on ADO.NET parameters.

Thirdly, while not essential, it is considered good practice to specify the columns you're inserting to explicitly.

As for the question, ExecuteScalar is specifically intended for queries that produce a result set containing a single column and a single row. If you want multiple rows and/or multiple columns then you don't use ExecuteScalar. You would call Fill on a DataAdapter or else call ExecuteReader and use a DataReader.
 
hi jmcilhinney,

I think u have not understood my query........

my problem is i am not able to retrieve the nchar data in the oracle field into my textfield as i entered during saving the record.

Thanks
in advance
 
Looks like a unicode to (non unicode) character conversion problem. I note that you have not specified unicode in your connection string, but I'd actually like you to try the recommended way of doing data access instead of what you have here.

Read the DW2 link in my signature, section "Creating a Simple Data App"

See if the test app you make there will save your unicode characters properly. If not, I suggest you look at your oracle setup and make sure the character set in use for your session

Pages such as this may offer some advice:
Unicode support with Oracle
 
Back
Top