Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trigger to connect to server

Status
Not open for further replies.

cmsbuffet

Programmer
Feb 3, 2009
173
CA
How do I write a trigger to connect with a server?
 
That just doesn't sound like a good idea to me. Perhaps you can explain the goal and we can come up with a better idea.
 
I have a procedure in SSMS. I also have a few labels, a textbox and a button in .net that I would like to connect to the procedure. But the tutorial, from which I got this idea, is for .net 2.0. Whereas, my .net is 3.5. (VS 20008).

Here is the link for the tutorial.
 
Er, OK so I guess when you said "trigger" you were not talking about a database trigger (for when a row is added, edited, or deleted). "Trigger" has a very specific meaning in databases - and it generally would not be a good place to do something extravagent like connecting to another database server. But I guess that's not what you meant.

As for the tutorial, the code in it should work just as well in VS2008. .NET did not really change between versions 2.0 and 3.5, it just expanded. The one thing that may have changed a little is that there is now a GridView control instead of the DataGrid (although you could still use the DataGrid if you wanted to).
 
I could not find an Import Option in VS2008

To access SQL Server databases, you must [red] import[/red] the System.Data.SqlClient namespace, which provides new objects such as the SqlDataReader and the SqlDataAdapter objects. You can use SqlDataReader to read a forward-only stream of rows from a SQL Server database. DataAdapter represents a set of data commands and a database connection that you can use to fill the DataSet object and to update a SQL Server database.
What can I do instead, or where is Import Option?
 
Why I cannot find DataReader object in VS2008? I go to VS2008, open Web Form, find Toolbox, find Data, but there is no DataReader there...
 
It's not a visual tool. Have you tried following the steps in the tutorial? It certainly does not say to drag a "DataReader" from the toolbox.
 
Ok, I will try to follow the tutorial code more closely. However, when I paste the code in step 3, then I get the following code highlighted

Code:
"create procedure GetAuthorsByLastName (@au_lname varchar(40), " & _

                            "@RowCount int output) " & _ 

                            " as select * from authors where au_lname like @au_lname; select @RowCount=@@ROWCOUNT"

And an error pops up - [red]&[/red] is highlighted and an error says an expression is expected. There are also two more syntax errors, where [red]"@RowCount int output) "[/red] and [red] " as select * from authors where au_lname like @au_lname; select @RowCount=@@ROWCOUNT"[/red] are highlighted.
 
For the previous error I fixed it by putting the 3 lines in the code together on one line.

I am trying out the compilation right now.

I have the following code
Code:
                'Open the connection.
                .Connection.Open()
It gives an error [red]slqException was unhandled by user code[/red]. What is supposed to be instead of Connection? Or is it another thing that causes the error?
 
I don't know what to put into config file, may be that's why this error comes up?
 
I am trying to create a new database in solution explorer by right-clicking on the data connections. It gives an error
"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Coulnd not open a connection to SQL server)"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top