Click here to Skip to main content
15,923,168 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionI cant a Button control with two images status >> Pin
kindman_nb17-Nov-06 22:53
kindman_nb17-Nov-06 22:53 
AnswerRe: I want a Button control with two images status >> Pin
kindman_nb17-Nov-06 23:06
kindman_nb17-Nov-06 23:06 
AnswerRe: I cant a Button control with two images status >> Pin
Christian Graus17-Nov-06 23:07
protectorChristian Graus17-Nov-06 23:07 
AnswerRe: I cant a Button control with two images status >> Pin
MohammadAmiry17-Nov-06 23:07
MohammadAmiry17-Nov-06 23:07 
Questionvb.Net vs SQL Sever Datatypes Pin
RichardBerry17-Nov-06 21:48
RichardBerry17-Nov-06 21:48 
AnswerRe: vb.Net vs SQL Sever Datatypes Pin
RichardBerry17-Nov-06 22:53
RichardBerry17-Nov-06 22:53 
GeneralRe: vb.Net vs SQL Sever Datatypes Pin
Colin Angus Mackay19-Nov-06 2:39
Colin Angus Mackay19-Nov-06 2:39 
GeneralRe: vb.Net vs SQL Sever Datatypes Pin
RichardBerry19-Nov-06 21:15
RichardBerry19-Nov-06 21:15 
Colin Angus Mackay wrote:
This may sound totally stupid, but have you considered developing on a COPY of the database? That way you have a development/test database that looks like the live database, but you are free to completely bugger up when accidents happen (and they will happen).


OK, point taken - I should have a solution to this in a day or so, we are moving to a new server, so I will keep the old server for testing


Colin Angus Mackay wrote:

DBNull


The DBNULLS were returned on a record that is typical of all records (i.e. all our stock items do not use this field, so should be ok if a dbnull is written back for this field

Colin Angus Mackay wrote:
Do you mean that each row contains pretty much the same data except for the 19 changed columns?


Yes, the values of all the fields are the same for each stock item, except for 19 fileds which are unique and contain data such as product code, standard cost, lead time etc.

Perhaps I can explain a bit about the code I have written (but NOT tested yet and you can suggest the best way of doing it)

First I create a datatable 'dtXlData' with 19 columns - datatype System.String

I then pull the Excel data into into this table.

'Import Data From EXCEL...
Dim cmd As New System.Data.OleDb.OleDbCommand("Select * from [ImportData$A:T]", conn)
            Dim rdr As Data.OleDb.OleDbDataReader = cmd.ExecuteReader
            Do While rdr.Read()
                dr = dtXlData.NewRow
                 For col As Integer = 0 To 18
                    If rdr.IsDBNull(col) Then
                        dr.Item(col) = ""
                    Else
                        dr.Item(col) = rdr.GetValue(col).ToString
                    End If
                Next
                dtXlData.Rows.Add(dr)
            Loop


Using above, i cannot really force different datatypes for each column, so that is why I pull everything in as String

I then pull one 'template' row from the SQL Server. This is dtStockm, and equate a datarow drStockm to a sample row from this table

I then loop through the dtXlData table and create an Insert Statement for each row of import data, alter the CommandText, and ExecuteNonQuery for each row of the new data. The code looks as follows:

Try
            cn.Open()
            For i = 0 To dtXlData.Rows.Count - 1
                strInsertString = "stockm.on_order_qty, stockm.price, " _
                & "stockm.weight,  ..... to field 187" _
                & "VALUES (" & dtXlData.Rows(i).Item(0) & ","  _
                & dtXlData.Rows(i).Item(1) & "," 
                & "," & drStkm.Item(0) .... to Field 187
                cmd.CommandText = strInsertString
                cmd.ExecuteNonQuery()
            Next


From the above, you can see, that for the fields that are NOT changing, I'm using the values from the 'template' datarow (drStkm.Item(n) and for the 19 fields that DO change, I use the data from the Excel imported table (dtXlData.Rows(i).Item(n)). I think I need to still add a Ctype(drStkm.Item(n),Gettype(System.Data.Sqltypes.Chars)) for each of the 19 fields that get imported.

Is it ok to change the Command.Text while the connection is open, Or do I have to close the connection change the command text and re-open it for each row?

Is System.Data.Sqltypes.Chars the correct datatype for CHAR n?

Do you think this will work, or will a Parameterised query be easier?

Will the Datatypes of the 'Template' row be maintained and written back correctly? (I use DataAdapter.Getschema and DataAdapter.Fill when getting the 'template row from the SQL server)

Thanks for your help so far...
QuestionHow to make multi language interface program ?? Pin
kindman_nb17-Nov-06 20:46
kindman_nb17-Nov-06 20:46 
AnswerRe: How to make multi language interface program ?? Pin
MohammadAmiry17-Nov-06 23:11
MohammadAmiry17-Nov-06 23:11 
GeneralRe: How to make multi language interface program ?? Pin
kindman_nb17-Nov-06 23:48
kindman_nb17-Nov-06 23:48 
QuestionHow to find - Windows Applicatin Bootup Disk? Pin
Anandan k17-Nov-06 20:30
Anandan k17-Nov-06 20:30 
AnswerRe: How to find - Windows Applicatin Bootup Disk? Pin
Dave Kreskowiak18-Nov-06 5:22
mveDave Kreskowiak18-Nov-06 5:22 
AnswerHow to find - System Bootup Disk in Windows Application(XP)? Pin
Anandan k20-Nov-06 23:23
Anandan k20-Nov-06 23:23 
Questionproblem with windows service - msgbox problem Pin
BSRK17-Nov-06 19:08
BSRK17-Nov-06 19:08 
AnswerRe: problem with windows service - msgbox problem Pin
MatrixCoder19-Nov-06 22:09
MatrixCoder19-Nov-06 22:09 
QuestionHow do I delete all files in a folder? Pin
Code Crapper17-Nov-06 14:18
Code Crapper17-Nov-06 14:18 
AnswerRe: How do I delete all files in a folder? Pin
Christian Graus17-Nov-06 15:08
protectorChristian Graus17-Nov-06 15:08 
GeneralRe: How do I delete all files in a folder? Pin
Code Crapper18-Nov-06 12:36
Code Crapper18-Nov-06 12:36 
GeneralRe: How do I delete all files in a folder? Pin
Christian Graus18-Nov-06 12:55
protectorChristian Graus18-Nov-06 12:55 
AnswerRe: How do I delete all files in a folder? Pin
Janani Divya17-Nov-06 15:22
Janani Divya17-Nov-06 15:22 
AnswerRe: How do I delete all files in a folder? Pin
The ANZAC18-Nov-06 13:24
The ANZAC18-Nov-06 13:24 
GeneralRe: How do I delete all files in a folder? Pin
Code Crapper19-Nov-06 2:14
Code Crapper19-Nov-06 2:14 
QuestionHow to open and view TIF in Access Pin
Tech.Wizard17-Nov-06 13:19
Tech.Wizard17-Nov-06 13:19 
QuestionProblem: .NET 2.0 File.GetLastWriteTime(path) Keeps adding 1 hour Pin
zonkerman17-Nov-06 13:12
zonkerman17-Nov-06 13:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.