[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Insert Openquery to Oracle server from asp.net

Posted on 2010-08-31
5
Medium Priority
?
643 Views
Last Modified: 2012-06-27
Before the following sql statment went to a sql server so it was no problem but now i need to send it over a linked server to an oracle server, how can i change this to use openquery insert.

sql = "Insert tblACNRequest (strAcn, intRecruitId, intRecruiterRecordid, strUic, strPara, strLine, strGrade, strDmos, strNotes, dtExpire, dtTimeStamp) " _
            & "Values ('" & lblAcnNum.Text & "', " & Session("id") & ", " & lblhidden.Text & ", '" & lblUIC.Text & "', '" & lblPara.Text & "', " _
            & "'" & lblLine.Text & "', '" & lblGrade.Text & "', '" & lblDmos.Text & "', '" & txtNotes.Text & "', '" & lblACNDate.Text & "', '" & Date.Now() & "')"
Oracle server statement

sql = "INSERT OPENQUERY(SIDPERS, 'Select ??????')
Values ('" & lblAcnNum.Text & "')

Open in new window

0
Comment
Question by:kdeutsch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 40

Accepted Solution

by:
lcohan earned 1400 total points
ID: 33569836
Assuming you run it from SQL against ORACLE Lin ked Server you should run something like the statement below but where the VALUES must be replaced with the actual value - you can use variables for each of the values in the list then build a string and in the end exec(print first for debuging) that string.

INSERT INTO OPENQUERY(SIDPERS,
'SELECT strAcn, intRecruitId, intRecruiterRecordid, strUic, strPara, strLine, strGrade, strDmos, strNotes, dtExpire, dtTimeStamp FROM tblACNRequest')
values (lblAcnNum, Session(id), lblhidden, lblUIC, lblPara, lblLine, lblGrade, lblDmos, txtNotes, lblACNDate, Date);
0
 

Author Comment

by:kdeutsch
ID: 33588373
lcohan:

Well, I tried it but for some reason my values are not being picked up by the insert string.

Here is the code I am useing on myVb page.
 Private Sub lnkSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkSubmit.Click
        Dim Acn As String = 11 - 222 - 1
        Dim SSN As String = "333333333"
        Dim ACNStat As Integer = 4
        Dim TimeStamp As String = Date.Now()
        Dim logon As String = Split(Current.User.Identity.Name, "\")(1)
        Dim DtExpire As String = lblACNDate.Text
        Dim RecruitId As Integer = Session("id")
        Dim RecruiterID As Integer = lblhidden.Text
        Dim Uic As String = lblUIC.Text
        Dim Para As String = lblPara.Text
        Dim Line As String = lblLine.Text
        Dim Grade As String = lblGrade.Text
        Dim Dmos As String = lblDmos.Text
        Dim Notes As String = Replace(txtNotes.Text, "'", "''")

        Acn = "11-222-1"


        'Generate new SID #
        'GenerateNewId()
        sql = "Select strSSN from tblRecruit where intRecruitId = " & Session("id")
        myDataTable = New DataTable
        myDataTable = getData(sql)

        SSN = myDataTable.Rows(0)(0)

        'Save all the information and Create ACN number
        sql = "INSERT INTO OPENQUERY(SIDPERS, 'SELECT ACN, SSN_SM, ACN_STATUS, DT_ISSUED, ISSUED_BY, DT_EXPIRE, RSID, NCOID, UIC, PARA, LINE, REMARKS, GRADE, MOS FROM ACN.ACN_CNTL_NBR_TBL') " _
                & "values (ACN, SSN, ACNSTat, TimeStamp, logon, DtExpire, RecruitId, RecruiterID, Uic, Para, Line, Grade, Notes, Grade, Dmos);"

        Response.Write(sql)
        Response.End()
        insertUpdateDelete(sql)
0
 

Author Comment

by:kdeutsch
ID: 33588432
Never mind being retarded today forgot to add the " & Value & "
0
 

Author Comment

by:kdeutsch
ID: 33620352
Ok, finally got permissions to this table and it worked fine, Thanks
0
 

Author Closing Comment

by:kdeutsch
ID: 33620362
Thanks
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
This video shows how to recover a database from a user managed backup
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question