Click here to Skip to main content
15,913,709 members
Home / Discussions / Database
   

Database

 
GeneralImport Stored Procedure Pin
Richard Hudson15-Oct-03 5:19
Richard Hudson15-Oct-03 5:19 
GeneralRe: Import Stored Procedure Pin
Mike Dimmick16-Oct-03 5:08
Mike Dimmick16-Oct-03 5:08 
Generalforeign key Pin
Anonymous15-Oct-03 4:32
Anonymous15-Oct-03 4:32 
GeneralKill Sleeping Database Connections in SQL Server Pin
Altafqau15-Oct-03 0:17
Altafqau15-Oct-03 0:17 
GeneralRe: Kill Sleeping Database Connections in SQL Server Pin
Sage16-Oct-03 11:18
Sage16-Oct-03 11:18 
GeneralRe: Kill Sleeping Database Connections in SQL Server Pin
Altafqau16-Oct-03 23:49
Altafqau16-Oct-03 23:49 
GeneralADO and Pro-C Pin
WoonLeng13-Oct-03 19:56
WoonLeng13-Oct-03 19:56 
QuestionUpload File into SQL Server? Pin
DudleyDoorite13-Oct-03 4:34
DudleyDoorite13-Oct-03 4:34 
I have done some research on some different newsgroups
and website and think I have figured out how to upload a
document file into my SQL Server. below is the code I am
using, but it never store the data into the database. I
do not get any error messages so I assume it works, but when
I check the table, there is no data. Is there something I am missing?

Thanks for your help.

<br />
    Public Function StoreFile(ByVal FileData As Byte(), ByVal ServerName As String, ByVal SqlPassword As String, ByVal SqlUser As String)<br />
        'Make the Connection to the SQL server<br />
        Dim ConnectionString As String = ""<br />
        ConnectionString = ConnectionString & "data source=" & ServerName & ";"<br />
        ConnectionString = ConnectionString & "password=" & SqlPassword & ";"<br />
        ConnectionString = ConnectionString & "persist security info=False;"<br />
        ConnectionString = ConnectionString & "user id=" & SqlUser & ";"<br />
        'ConnectionString = ConnectionString & "packet(Size = 4096)"<br />
<br />
        Try<br />
            'Declare the Connection Object.<br />
            Dim Conn As SqlConnection = New SqlConnection(ConnectionString)<br />
            'Open the Connection.<br />
            Conn.Open()<br />
<br />
<br />
            'Declare a DataAdapter.<br />
            Dim DA As SqlDataAdapter = New SqlDataAdapter()<br />
<br />
            'Set the Select,Delete,Insert, and Update Command for this DataAdapter<br />
            DA.SelectCommand = New SqlCommand("SELECT DOC_Type, DOC_Data, DOC_ID FROM EDIAPPS.dbo.Documents_All", Conn)<br />
            DA.InsertCommand = New SqlCommand("INSERT INTO EDIAPPS.dbo.Documents_All(DOC_Type, DOC_Data) VALUES (@DOC_Type, @DOC_Data); SELECT DOC_Type, DOC_Data, DOC_ID FROM EDIAPPS.dbo.Documents_All WHERE (DOC_ID = @@IDENTITY)", Conn)<br />
            DA.UpdateCommand = New SqlCommand("UPDATE EDIAPPS.dbo.Documents_All SET DOC_Type = @DOC_Type, DOC_Data = @DOC_Data WHERE (DOC_ID = @Original_DOC_ID) AND (DOC_Type = @Original_DOC_Type); SELECT DOC_Type, DOC_Data, DOC_ID FROM EDIAPPS.dbo.Documents_All WHERE (DOC_ID = @DOC_ID)", Conn)<br />
            DA.DeleteCommand = New SqlCommand("DELETE FROM EDIAPPS.dbo.Documents_All WHERE (DOC_ID = @Original_DOC_ID) AND (DOC_Type = @Original_DOC_Type)", Conn)<br />
<br />
            'Delclare a dataSet Object.<br />
            Dim DS As New DataSet()<br />
<br />
            'Fill the Dataset with the Table data from the Database.<br />
            DA.Fill(DS)<br />
<br />
            'Delclare a New DataRow Object.<br />
            Dim DR As DataRow = DS.Tables(0).NewRow<br />
<br />
            'Populate the new row with our information.<br />
            DR("DOC_Type") = 1<br />
            DR("DOC_Data") = FileData<br />
<br />
            'Add New Row to out DataSet.<br />
            DS.Tables(0).Rows.Add(dr)<br />
            DS.AcceptChanges()<br />
<br />
            'Update the Database with our changes.<br />
            DA.Update(DS)<br />
            Conn.Close()<br />
        Catch Ex As Exception<br />
            MessageBox.Show(Ex.Message, "Application Error", MessageBoxButtons.OK)<br />
            Return False<br />
        Catch DBE As SqlClient.SqlException<br />
            MessageBox.Show(DBE.Message, "SQL Error", MessageBoxButtons.OK)<br />
            Return False<br />
        Finally<br />
        End Try<br />
<br />
    End Function<br />

Confused | :confused:

=================================
When I was in school, all I wanted was to get out into the real world.
Now that I'm in the real world, all I want is to go back to school.
GeneralDataRow/DataGrid filter question. Pin
TravisMerkel12-Oct-03 13:06
TravisMerkel12-Oct-03 13:06 
GeneralRe: DataRow/DataGrid filter question. Pin
Armen Dalaliants16-Oct-03 4:02
Armen Dalaliants16-Oct-03 4:02 
GeneralSQL syncing Pin
Judah Gabriel Himango10-Oct-03 6:10
sponsorJudah Gabriel Himango10-Oct-03 6:10 
GeneralRe: SQL syncing Pin
Rob Graham10-Oct-03 12:32
Rob Graham10-Oct-03 12:32 
GeneralSQL syncing Pin
Guillermo Rivero13-Oct-03 3:34
Guillermo Rivero13-Oct-03 3:34 
GeneralIdentity Pin
Anonymous9-Oct-03 8:22
Anonymous9-Oct-03 8:22 
GeneralRe: Identity Pin
Mike Dimmick9-Oct-03 23:07
Mike Dimmick9-Oct-03 23:07 
QuestionWay to monitor SQL Server programatically? Pin
darrinps8-Oct-03 6:19
darrinps8-Oct-03 6:19 
AnswerRe: Way to monitor SQL Server programatically? Pin
Blake Coverett8-Oct-03 15:40
Blake Coverett8-Oct-03 15:40 
GeneralRe: Way to monitor SQL Server programatically? Pin
darrinps9-Oct-03 2:37
darrinps9-Oct-03 2:37 
GeneralCDaoWorkspace Pin
OTVAC3058-Oct-03 0:26
OTVAC3058-Oct-03 0:26 
GeneralRe: CDaoWorkspace Pin
Hans-Georg Ulrich13-Oct-03 2:14
Hans-Georg Ulrich13-Oct-03 2:14 
GeneralRe: CDaoWorkspace Pin
OTVAC30513-Oct-03 2:22
OTVAC30513-Oct-03 2:22 
GeneralDatabase Connections in Sleeping State in SQL Pin
Anonymous7-Oct-03 1:32
Anonymous7-Oct-03 1:32 
GeneralRe: Database Connections in Sleeping State in SQL Pin
Mike Dimmick7-Oct-03 22:44
Mike Dimmick7-Oct-03 22:44 
GeneralRe: Database Connections in Sleeping State in SQL Pin
Anonymous8-Oct-03 23:55
Anonymous8-Oct-03 23:55 
GeneralGeneral Network Error Pin
yyf6-Oct-03 7:54
yyf6-Oct-03 7:54 

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.