Hi

sir i m new in vb.net . i want to add product record , in text box i enter packing 25's but 25's not add in table , when i change it 25s it saved. but my requirement is to save 25's. what i do

thanks
zia

Recommended Answers

All 4 Replies

Hi,
Sorry not 100% sure what you mean. Maybe some of the code you've written so far would help?

It's quite hard to understand what you're wanting. The problem could lie where you're setting datatable property. But if it's not, I suggest to dim a string first, insert later:

Dim Prdt as String
Prdt = TextBox1.Text.Trim
YourDataTable.Rows.Add(Prdt,Col1Value,Col12Value...)

To escape a single quote and other escape sequence chars, you need to use parameterized sql statement (SqlParameter, OleDbParameter etc).

Using cn As New SqlConnection(cnStr) 
    Dim sql = "INSERT INTO tableOne (col1) VALUES (@col1)"
    Using cmd as new SqlCommand(sql,cn)
       cmd.Parameters.AddWithValue("@col1","25's")
       cn.Open()
       cmd.ExecuteNonQuery()
       cn.Close()
    End Using
End Using

i think if your column datatype is not supported to 20's , if you are using mssql server then nvarchar datatype may help .

Regards

Be a part of the DaniWeb community

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