Showing posts with label integer. Show all posts
Showing posts with label integer. Show all posts

Monday, March 19, 2012

Currency Problem

I have a currency that needs to go into the Database. The column in the database is of type money.
When i try ctype or convert into integer, desimal or even sqlmoney type i get an error. Cannot convert data type nvarchar to data type money.

Can anyone help me with this Please.
Here is the code...

sqlcom = New SqlCommand("insert MeasureQuantities(MeasureQuantityName,MeasureQuantityDescrip,MeasureQuantityPrice) values(@.MeasureQuantityName,@.MeasureQuantityPrice,@.MeasureQuantityDescrip)", ocnn)
ocnn.Open()
Dim decPrice As System.Data.SqlTypes.SqlMoney
decPrice.ToDecimal()
decPrice = CType(MeasureQuantityPriceAdd.Text, System.Data.SqlTypes.SqlMoney)
sqlcom.Parameters.Add("@.MeasureQuantityName", MeasureQuantityNameAdd.Text)
sqlcom.Parameters.Add("@.MeasureQuantityPrice", decPrice) 'MeasureQuantityPriceAdd.Text, System.Data.SqlTypes.SqlMoney))
sqlcom.Parameters.Add("@.MeasureQuantityDescrip", MeasureQuantityDescripAdd.Text)
sqlcom.ExecuteNonQuery()What is the value of MeasureQuantityPriceAdd.Text? If the textbox is blank, you might be getting this error. Are you databinding the textbox on page load? If so, make sure you are checking if the page is a postback, and only populate it if the page is not a poatback.|||Thanks, the real problem was in the order of the variables in the update string.

Friday, February 17, 2012

csv import into ms sql 2000

I've got a csv file (75000 records) with 5 columns, one is a date of birth column which shows as an 8 digit long integer (yyyymmdd). I've tried sql dts but I just don't know how to show this column in sql as a date field in dd/mm/yyyy format. Can anyone please help?Using Excel you can change the cell format as you required & upload data in the SQL database but in Excel maximum row limit is 65536.

You can divide this data in two excel sheet & can proceed.

If you are not going to do this task frequently than it is fine, else find some better solution.|||Thanks Rajesh - i've tried that, the problem is that the date of birth field has no date separators, and being in number format, a excel just fills the cell with "###############". Today (2nd sept 2006) shows like an integer 20060902.
Thanks again for your quick reply.
Arthur|||Still Excel helps you lot. Check the enclosed file, it is self explanatory.

Add four columns next to your date column & add formulas same as enclosed file.

At the last check data then Copy -> Paste Special -> Value. Remove unwanted columns & upload data.

Little hard work but fruitful.|||Brilliant - all works well. Thanks a milliuon for all your help.