- 论坛徽章:
- 0
|
请问各位高手,请教一下如题所说的问题,存储过程想通过输入一个ID来查找记录~~~应该怎么样写?
- #!/usr/bin/perl
- use DBD::ADO;
- #ADO连接
- my $data_source = "DBI:ADO:driver={SQL Server};Server=192.168.104.46; database=Northwind;";
- my $user = "sa";
- my $password = "";
- #建立句柄
- my $dbh = DBI->connect($data_source,$user,$password, {RaiseError =>0,AutoCommit =>0,PrintError =>0})
- or die "Can't connect to $data_source: $DBI::errstr";
- #查询方法
- $sth=$dbh->prepare('proc_employee_query'); #存储过程(带有一个输入ID来查询)
- $sth->execute();
- print "EmployeeID\tFirstName\tLastName\n";
- while(my $ref = $sth->fetchrow_hashref()) { #输出记录
- print "$ref->{'EmployeeID'}\t";
- print "$ref->{'FirstName'}\t";
- print "$ref->{'LastName',}\n";
- }
- $sth->finish();
- #关闭句柄
- $dbh->disconnect();
复制代码
[ 本帖最后由 sean88 于 2007-2-8 17:56 编辑 ] |
|