Click here to Skip to main content
15,902,635 members
Home / Discussions / Database
   

Database

 
GeneralRe: Update a datatable to database Pin
Joe14-Feb-08 1:27
Joe14-Feb-08 1:27 
GeneralRe: Update a datatable to database Pin
Bluebamboo14-Feb-08 4:32
Bluebamboo14-Feb-08 4:32 
GeneralRe: Update a datatable to database Pin
Joe14-Feb-08 5:30
Joe14-Feb-08 5:30 
GeneralRe: Update a datatable to database Pin
Bluebamboo14-Feb-08 8:41
Bluebamboo14-Feb-08 8:41 
GeneralRe: Update a datatable to database Pin
Joe14-Feb-08 18:48
Joe14-Feb-08 18:48 
GeneralPassing Parameters to Strored Procedure Pin
dnsl13-Feb-08 23:36
dnsl13-Feb-08 23:36 
GeneralRe: Passing Parameters to Strored Procedure [modified] Pin
Vimalsoft(Pty) Ltd14-Feb-08 20:13
professionalVimalsoft(Pty) Ltd14-Feb-08 20:13 
GeneralRe: Passing Parameters to Strored Procedure Pin
Ashfield15-Feb-08 9:48
Ashfield15-Feb-08 9:48 
What you are attempting to do is pass values by position. This is generally considered bad practice as a change to the stored proc (ie adding a new parameter but not to the end of the list) could result in values being passed to the wrong column.

You can always do:

command.Parameters.Add(new SQLParameter("@name",value))

This uses the overload for new SQLParameter(name as String, Value as Object)

Better still, write a set of overloaded functions such as:
Public Overloads Sub AddParameter(ByVal parameterName As String, _<br />
                                      ByVal parameterValue As Boolean) <br />
        AddParameter(parameterName, parameterValue, System.Data.DbType.Boolean, System.Data.ParameterDirection.Input)<br />
    End Sub<br />
    Public Overloads Sub AddParameter(ByVal parameterName As String, _<br />
                                      ByVal parameterValue As Int32) <br />
        AddParameter(parameterName, parameterValue, System.Data.DbType.Int32, System.Data.ParameterDirection.Input)<br />
    End Sub<br />
<br />
 Public Overloads Sub AddParameter(ByVal parameterName As String, _<br />
                                      ByVal parameterValue As Object, _<br />
                                      ByVal dbType As System.Data.DbType, _<br />
                                      ByVal direction As System.Data.ParameterDirection)<br />
        Try<br />
            ' Add new parameter to command object - if already exists then simply update the value<br />
            If m_cmd.Parameters.Contains(parameterName) Then<br />
                m_cmd.Parameters(parameterName).Value = parameterValue<br />
            Else<br />
                Dim prm As SqlParameter = New SqlParameter<br />
<br />
                With prm<br />
                    .ParameterName = parameterName<br />
                    .Direction = direction<br />
                    .DbType = dbType<br />
                    .Value = parameterValue<br />
                End With<br />
                m_cmd.Parameters.Add(prm)<br />
            End If<br />
<br />
        Catch ex As Exception<br />
            Throw New ApplicationException(String.Format("Unable to add parameter {0} to command", parameterName), ex)<br />
        End Try<br />
    End Sub


Bob
Ashfield Consultants Ltd

Generalerror in local works fine in server Pin
new2pgrmg13-Feb-08 23:21
new2pgrmg13-Feb-08 23:21 
GeneralRe: error in local works fine in server Pin
Joe14-Feb-08 0:03
Joe14-Feb-08 0:03 
GeneralRe: error in local works fine in server Pin
new2pgrmg14-Feb-08 1:13
new2pgrmg14-Feb-08 1:13 
GeneralSaving Image Pin
mwanyu13-Feb-08 21:11
mwanyu13-Feb-08 21:11 
GeneralRe: Saving Image Pin
Giorgi Dalakishvili13-Feb-08 22:43
mentorGiorgi Dalakishvili13-Feb-08 22:43 
Generalreplace '1/1/1900' to NULL in MS SQL Pin
John Sundar13-Feb-08 20:39
John Sundar13-Feb-08 20:39 
GeneralRe: replace '1/1/1900' to NULL in MS SQL Pin
Colin Angus Mackay13-Feb-08 21:11
Colin Angus Mackay13-Feb-08 21:11 
GeneralIncluding MSSQL in a C# application for a client. Pin
AlainMesias13-Feb-08 15:51
AlainMesias13-Feb-08 15:51 
Generalcopy datarow Pin
Smithers-Jones13-Feb-08 10:01
Smithers-Jones13-Feb-08 10:01 
GeneralRe: copy datarow Pin
pmarfleet13-Feb-08 11:08
pmarfleet13-Feb-08 11:08 
GeneralRe: copy datarow Pin
Smithers-Jones13-Feb-08 11:45
Smithers-Jones13-Feb-08 11:45 
GeneralStored procedure returning dataset Pin
#realJSOP13-Feb-08 8:26
professional#realJSOP13-Feb-08 8:26 
GeneralRe: Stored procedure returning dataset Pin
pmarfleet13-Feb-08 11:07
pmarfleet13-Feb-08 11:07 
GeneralDeleting top 3 from a select [modified] Pin
Dio2213-Feb-08 7:42
Dio2213-Feb-08 7:42 
GeneralRe: Deleting top 3 from a select Pin
Dio2213-Feb-08 8:37
Dio2213-Feb-08 8:37 
QuestionBest way to store addresses ?? Pin
C. L. Phillip13-Feb-08 5:10
C. L. Phillip13-Feb-08 5:10 
GeneralRe: Best way to store addresses ?? Pin
Joe13-Feb-08 6:07
Joe13-Feb-08 6:07 

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.