Showing posts with label remote. Show all posts
Showing posts with label remote. Show all posts

Monday, March 26, 2012

How to save contents of Text box to database?

Hi,

For some reason I can't use the edit, update or insert features on my remote shared server, so I am looking to create a web page that has text boxes on it, that I can enter data into, that will be saved into my database.

This is opposed to entering the data directly into the database itself. I want to be able to use a webpage, for simply adding new data, and saving it so that the new data updates and saves over the top of the old data.

What are the steps involved in doing this?

Any example code for just one text box would be appreciated, I could then extend it to suit my needs. Tia.

As I understand you want to get data in text box in you website and then update or insert to the database table. Here I wrote a very simple sample in C#:

protected void Button1_Click(object sender, EventArgs e)
{
string connectionString = @."Data Source=Confute\SQL2000;Initial Catalog=tempdb;Integrated Security=SSPI;";

using (SqlConnection connection = new SqlConnection(connectionString))
{
// Connect to the database then retrieve the schema information.


SqlCommand cmd = new SqlCommand("sp_UpdateMytable", connection);
connection.Open();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@.id", txtBox_ID.Text);
cmd.Parameters.Add("@.name", txtBox_Name.Text);
int i = cmd.ExecuteNonQuery();

}

And the storedprocedure sp_UpdateMytable will update a table t1(id int, name varchar(30)) in this way:


create proc sp_UpdateMyTable @.id int,@.name varchar(30)
as
if exists (select * from t1 whereid=@.id)
update t1 setname=@.namewhere id= @.id
else insert into t1 select @.id,@.name
go

|||

Thanks Lori_Jay,

I actually resolved the issue and did switch the answered tag on this thread. I am sure your solution would work, however mine was a more simple issue, actually I will mention it here for other poor souls who struggle with the same issue I did.

Basically, I did not have a Primary Key set in my table of my database. Firstly, I was taught that although its a good idea to have a PK, it's not absolutely necessary. Because I had one table, with one column and one row, Idecided not to have one.

If you don't have one, then in Visual Studio 2005, you cannot access the Advanced SQL options, which are INSERT, UPDATE & DELETE, this seems to be a major fault if you ask me because there is ZERO error reporting and ZERO documentation about it.

I got lucky when I did a Google for it (after a week of endless suffering) to find one site in the entire world, written in Russian (which I had to translate very poorily), which stated that you need a PK. I quickly added a PK to my table and it worked instantly.

Perhaps the powers that be whom monitor these forums, can look into this and document it so that others are spared the same distress.

Regards.

Friday, March 23, 2012

How to Run DTS Package from remote server with SQL 2005

I am new to SQL Server and need to understand how to run DTS packages (SSIS) in SQL 2005 from a remote server? In other words run them from another server from where the database is installed.

I am looking for any links on the subject, guidance on how to set this up and how to use it.

Regards,

Lee

You just have to have the ssis runtime installed on the system you want to run the packages from. As long as you can make a connection from that machine to your database machine you should be ok. And of course you also need the workstation components installed on whatever machine you're doing your dev work from.

If you want to store your packages in the msdb db you may run into a problem because the default is to use the default instance on the local machine to connect to the msdb. There's a file you can edit to change this but I can't remember it off the top of my head.

|||If I correctly understard the question, you have a server where you have installed SSIS and some packages, and you want to start these packages from a remote computer (client), right?

The usual way to set this up is to create Agent Job that will run the package, without any schedule - so it would not run by itself. Then when you need to run the package from the client, you execute Agent stored proc (via SQL) to start the Job.|||

Hi Mike,

Thanks for the information. I will share this with the other developers working with me on this.

Lee

sql

Wednesday, March 21, 2012

How to run a stored procedure on SQL 2005 remote server?

hi,
i want to run one stored procedure on a remote SQL Server 2005, from
my machine.
can any one explain how to do this?
thanks
Kartheek
Hi Kartheek
"karthee" wrote:

> hi,
> i want to run one stored procedure on a remote SQL Server 2005, from
> my machine.
> can any one explain how to do this?
> thanks
> Kartheek
>
You don't say which edition of SQL Server 2005 you are using? If you have
SSMS then you can either connect directly to the server and run the
procedure, or create a linked server and run the procedure using four part
names or OPENQUERY etc. for more information check out books online. If you
have SQL Express you could use SQLCMD.
John

How to run a stored procedure on SQL 2005 remote server?

hi,
i want to run one stored procedure on a remote SQL Server 2005, from
my machine.
can any one explain how to do this?
thanks
KartheekHi Kartheek
"karthee" wrote:

> hi,
> i want to run one stored procedure on a remote SQL Server 2005, from
> my machine.
> can any one explain how to do this?
> thanks
> Kartheek
>
You don't say which edition of SQL Server 2005 you are using? If you have
SSMS then you can either connect directly to the server and run the
procedure, or create a linked server and run the procedure using four part
names or OPENQUERY etc. for more information check out books online. If you
have SQL Express you could use SQLCMD.
John

How to run a stored procedure on SQL 2005 remote server?

hi,
i want to run one stored procedure on a remote SQL Server 2005, from
my machine.
can any one explain how to do this?
thanks
KartheekHi Kartheek
"karthee" wrote:
> hi,
> i want to run one stored procedure on a remote SQL Server 2005, from
> my machine.
> can any one explain how to do this?
> thanks
> Kartheek
>
You don't say which edition of SQL Server 2005 you are using? If you have
SSMS then you can either connect directly to the server and run the
procedure, or create a linked server and run the procedure using four part
names or OPENQUERY etc. for more information check out books online. If you
have SQL Express you could use SQLCMD.
John

Monday, March 12, 2012

How to return a varchar from sproc on remote Linked Server?

The following T-SQL 2005 snippet executes a remote sproc on an Oracle database.

DECLARE@.OutParamVARCHAR(5)

EXEC('{Call getnextpin(1)}')ATALTTEST

GetNextPin takes a single input parameter.

I need to modify the above code snippet to return the next PIN number into @.OutParam.

Any ideas?

Any help appreciated.

Regards,

Paul.

Hi wadep,

Try the following code and see if it solves your problem ( i suppose your table has a primary key named "number_index" and your table is ordered well. If not, you need to use cursor which will be a little complicated)

create procedure getnextpin@.indexint,@.numberint outputasselect top 1 @.number=pin_number from your_table_namewhere number_index>@.indexreturn
-------- call proceduredeclare @.indexint, @.numberintset @.index=whatever_you_wantexecute getnextpin @.index,@.number outputprint @.number -- see if your number can be printed here
Hope my suggestion helps

Friday, February 24, 2012

How to retrieve current date and time from SQL2005 server.

well i'm using java to connect to SQL 2005 server. i need to retrieve it's current time and date on the sql 2005 server and use it on my remote desktop

thanks.

Hi,

You can use the following query :

SELECT getdate() as myDate

wich will give you somthing like "2006-10-27 11:29:15.373"

Regards