i keep on getting this error message incorrect syntax in line1... funny thing is when i execute every thing from SQL Query Analyzer it works just fine but when I'm executing the stored procedure from .net i keep on getting the errro message that I've mentioned above..
my sql stored procedure code snippet is given bellow
Generate PROCEDURE dbo.OracleStudentTbl
@tblName as varchar(255)
DECLARE @SQL as varchar(8000)
DECLARE @tbl as varchar(255)
SET @tbl =@tblName
'INSERT INTO [dbo].['+@tbl+']'
SELECT * FROM OPENQUERY(XXXX 'SELECT * FROM vw_student_details_forsurvey')
fundamentally what my stored procedure is doing is fetching a table name from my vb.net windows form then passing it to the stored procedure, then my SELECT * FROM OPENQUERY is populating the the table with its info... but as i mentioned i receive the syntax error...my code in my command button on vb.net is given bellow
Private Sub butSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butSave.Click
Dim varDetails As String = txtDetails.Text + "_" + txtDetailsTblName.Text
Dim sqlCommandDetailsInsert As New SqlCommand("OracleStudentTbl", connStr)
sqlCommandDetailsInsert.CommandType = CommandType.StoredProcedure
'this command is sending to the stored procedure the table name for the Students Details Table so that
'student details table will be populated with the data from the Oracle See
sqlCommandDetailsInsert.ExecuteNonQuery() ' receive error here when I'm debbuging my windows forms
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Info, "ErrorIn Code")
Dim frmMain As New frmMain
frmMain.mySQLname = var
would applaud assist pls..