Showing posts with label basic. Show all posts
Showing posts with label basic. Show all posts

Sunday, March 25, 2012

ActiveX info

I'm getting a little confused about what is supported in MS-SQL ActiveX and
what is Visual Basic and what is VBScript. Can someone please point me to a
website, recommend a book or if I've missed it where in the MS-SQL help that
deals with the ActiveX supported in SQL. I'm not looking to do web pages
ASP, ect. I'm looking to use the ActiveX as add on funtionality to support
the Stored Procs I write.

Thanks,

-pPippen (123@.hotmail.com) writes:
> I'm getting a little confused about what is supported in MS-SQL ActiveX
> and what is Visual Basic and what is VBScript. Can someone please point
> me to a website, recommend a book or if I've missed it where in the
> MS-SQL help that deals with the ActiveX supported in SQL. I'm not
> looking to do web pages ASP, ect. I'm looking to use the ActiveX as add
> on funtionality to support the Stored Procs I write.

Personally I get confused only I see the term ActiveX. I think it is the
same as OLE, but I might be completely wrong.

Anyway, to call OLE objects from SQL Server you can use the sp_OAxxxx
routines, documented in Books Online.

Beware that if you call OLE objects that reside on the same machine as
SQL Server, they execute in-process, which means that an access violation
or similar execution error can cause the whole SQL Server to crash. While
this is useful at times, it something to use with caution.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns959C1FC09AB7Yazorman@.127.0.0.1...
> Pippen (123@.hotmail.com) writes:
>> I'm getting a little confused about what is supported in MS-SQL ActiveX
>> and what is Visual Basic and what is VBScript. Can someone please point
>> me to a website, recommend a book or if I've missed it where in the
>> MS-SQL help that deals with the ActiveX supported in SQL. I'm not
>> looking to do web pages ASP, ect. I'm looking to use the ActiveX as add
>> on funtionality to support the Stored Procs I write.
> Personally I get confused only I see the term ActiveX. I think it is the
> same as OLE, but I might be completely wrong.
> Anyway, to call OLE objects from SQL Server you can use the sp_OAxxxx
> routines, documented in Books Online.
> Beware that if you call OLE objects that reside on the same machine as
> SQL Server, they execute in-process, which means that an access violation
> or similar execution error can cause the whole SQL Server to crash. While
> this is useful at times, it something to use with caution.
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techin.../2000/books.asp

After re-reading my post I did not make myself very clear... Please let me
try again. I'm looking to find resources to write ActiveX code to support my
stored procs ect... I'm confused on what the built in ActiveX compiler uses
out of the VBScript language. All of the VBScript books I pick up look like
they are written for web designers. I'm looking for a book or resource for
writing code for the ActiveX compiler in MS-SQL.

Sorry for the confusion,

-p|||Like a lot of Microsoft technology terms, ActiveX is a bit nebulous. Here's
a link to google definitions:
http://www.google.com/search?source...fine%3A+activex

The main concept is that ActiveX is a technology/API rather than a language.
One can write a script in a language like VBScript and then execute it using
SQL Server tools like a DTS ActiveX Script task, a SQL Server Agent ActiveX
Script job step or using the sp_OA* procs that Erland mentioned. The script
can also be run independently of SQL Server using Windows Scripting Host.

What functionality do you need to implement?

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Pippen" <123@.hotmail.com> wrote in message
news:ajUjd.483788$mD.296273@.attbi_s02...
> "Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
> news:Xns959C1FC09AB7Yazorman@.127.0.0.1...
>> Pippen (123@.hotmail.com) writes:
>>> I'm getting a little confused about what is supported in MS-SQL ActiveX
>>> and what is Visual Basic and what is VBScript. Can someone please point
>>> me to a website, recommend a book or if I've missed it where in the
>>> MS-SQL help that deals with the ActiveX supported in SQL. I'm not
>>> looking to do web pages ASP, ect. I'm looking to use the ActiveX as add
>>> on funtionality to support the Stored Procs I write.
>>
>> Personally I get confused only I see the term ActiveX. I think it is the
>> same as OLE, but I might be completely wrong.
>>
>> Anyway, to call OLE objects from SQL Server you can use the sp_OAxxxx
>> routines, documented in Books Online.
>>
>> Beware that if you call OLE objects that reside on the same machine as
>> SQL Server, they execute in-process, which means that an access violation
>> or similar execution error can cause the whole SQL Server to crash. While
>> this is useful at times, it something to use with caution.
>>
>>
>> --
>> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
>>
>> Books Online for SQL Server SP3 at
>> http://www.microsoft.com/sql/techin.../2000/books.asp
> After re-reading my post I did not make myself very clear... Please let me
> try again. I'm looking to find resources to write ActiveX code to support
> my stored procs ect... I'm confused on what the built in ActiveX compiler
> uses out of the VBScript language. All of the VBScript books I pick up
> look like they are written for web designers. I'm looking for a book or
> resource for writing code for the ActiveX compiler in MS-SQL.
> Sorry for the confusion,
> -p|||Pippen (123@.hotmail.com) writes:
> After re-reading my post I did not make myself very clear... Please let
> me try again. I'm looking to find resources to write ActiveX code to
> support my stored procs ect... I'm confused on what the built in ActiveX
> compiler uses out of the VBScript language. All of the VBScript books I
> pick up look like they are written for web designers. I'm looking for a
> book or resource for writing code for the ActiveX compiler in MS-SQL.

Since, as Dan said, no one really knows what ActiveX (save, possibly,
for the marketers that invented the term), it may be easier if you told
us what your business problem is.

Now it sounds a bit like you are asking to access SQL Server from ActiveX.
In such I assume that you use the ActiveX Data Objects, that is ADO. David
Sceppa has a good book about ADO on Microsoft Press. It's a bit old, so I
don't know how easy it is to get hold of.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns959C688EF43EAYazorman@.127.0.0.1...
> Pippen (123@.hotmail.com) writes:
>> After re-reading my post I did not make myself very clear... Please let
>> me try again. I'm looking to find resources to write ActiveX code to
>> support my stored procs ect... I'm confused on what the built in ActiveX
>> compiler uses out of the VBScript language. All of the VBScript books I
>> pick up look like they are written for web designers. I'm looking for a
>> book or resource for writing code for the ActiveX compiler in MS-SQL.
> Since, as Dan said, no one really knows what ActiveX (save, possibly,
> for the marketers that invented the term), it may be easier if you told
> us what your business problem is.
> Now it sounds a bit like you are asking to access SQL Server from ActiveX.
> In such I assume that you use the ActiveX Data Objects, that is ADO. David
> Sceppa has a good book about ADO on Microsoft Press. It's a bit old, so I
> don't know how easy it is to get hold of.
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techin.../2000/books.asp

After doing a little more research I think what I'm looking for is a book or
resource that deals with using VBScript in a DTS package to extend the
functionality of the DTS package; namely the ActiveX task in the DTS
package. Every book that I have picked up on VBScript deals primarliy with
webpages.

I have a process that needs to send and receive files that are encrypted
with PGP on a daily basis. Each of the files have unique names so I will
need to read tables to find the files that need to be processed. These files
will be encrypted / decrypted in the VBScript and loaded or extracted from
the DB. I would have used batch files (MS system) if not for the unique file
names. Essentially I'm looking to increase my knowledge of using VBScript in
an ActiveX task for this project and future projects.

Sorry about the misuse of normenclature, SQL is not my primary language.

Thanks,

-p|||Pippen (123@.hotmail.com) writes:
> After doing a little more research I think what I'm looking for is a
> book or resource that deals with using VBScript in a DTS package to
> extend the functionality of the DTS package; namely the ActiveX task in
> the DTS package. Every book that I have picked up on VBScript deals
> primarliy with webpages.

I know very little about DTS, and even less about books on DTS. However,
SQL Server MVPs Darren Green and Allen Mitchell runs www.sqldts.com, and
you might find some good tips there.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

Friday, February 24, 2012

Accessing the sample database in Visual Basic .net sqlDataAdapter

I need some help with accessing the sample databases with
the SqlDataAdapter.
After double-clicking on SqlDataAdapter in Visual
Basic .net. I click on new connection and choose
Microsoft Ole DB Provider for SQL Server as the
provider. Then under the connection tab, I enter (local)
as the server name. And Choose Use Windows NT Inegrated
Security. Then under databases in the server, only
master, model, msdb, and tempdb show up. The sample
databases Northwind and pubs don't show up, as well as
the database which I created called Project.
In the SQL Server Enterprise Manager, under Console Root -
> Microsoft SQL Server -> SQL Server Group -> CR304216-
A\Project[WindowsNT] -> Databases
I see master, model, msdb, Northwind, Project, pubs, and
tempdb.
So, why don't I see Northwind, Project, and pubs in the
sqlDataAdapter console?Hi, Sabrina!
I'm fairly new to VB.net, but I'm working hard at learning it each day.
Anyway, have you tried using the "sa" user name (or better yet... just the u
ser name and password to one of the databases you have access to)? I tend t
o not use the Windows security and go with the user name and password provid
ed for SQL Server instead (
I seem to have problems getting connections the other way).
I would try that and see what happens.
Hope that helps.
Rick
-- Sabrina wrote: --
I need some help with accessing the sample databases with
the SqlDataAdapter.
After double-clicking on SqlDataAdapter in Visual
Basic .net. I click on new connection and choose
Microsoft Ole DB Provider for SQL Server as the
provider. Then under the connection tab, I enter (local)
as the server name. And Choose Use Windows NT Inegrated
Security. Then under databases in the server, only
master, model, msdb, and tempdb show up. The sample
databases Northwind and pubs don't show up, as well as
the database which I created called Project.
In the SQL Server Enterprise Manager, under Console Root -
> Microsoft SQL Server -> SQL Server Group -> CR304216-
A\Project[WindowsNT] -> Databases
I see master, model, msdb, Northwind, Project, pubs, and
tempdb.
So, why don't I see Northwind, Project, and pubs in the
sqlDataAdapter console?

Sunday, February 19, 2012

Accessing Table From Visual Basic

I have a SQL table and I want to access it using the Visual Basic Code

but first I want to check whether the row is exist to update it or not exist so I can add new row. I have wrote this code but it doesn't work.

Set mydb2 = ceg.OpenResultset("select * from ProjCost where Mon='" _
& Format(SD, "dd/MM/yyyy") & "'", rdOpenDynamic, 3)
If mydb2.EOF Then
mydb2.AddNew
mydb2(0) = Trim(ProjNum)
mydb2(1) = Trim(ProjName)
mydb2(2) = Format(SD, "MM/dd/yyyy")
mydb2(3 + (mydb1(0) - 1) * 2) = Trim(Total)
mydb2.Update
Else
mydb2.Edit
mydb2(3 + (mydb1(0) - 1) * 2) = Trim(Total)
mydb2.Update
End If

can any body tell me what is wrong with this code as it's every time add a new record instead of updating the exisitng one

Thnx

Look at your query in Profler (or just output it into any debug window) and try to run it from QA, for examlpe.
P.S. Hint: datetime field may contain time as well, Then your query will return only rows with midnight time.

Thursday, February 16, 2012

accessing SQL Server Compact Edition from VBA

Is it possible to connect to SQL Server Compact Edition with Visual Basic for Application?

I want to connect to *.sdf file from MS Access.

I suppose you can do it using OLEDB if VBA allows you to use COM objects (which you should know better as I've never used VBA).

|||

Thanks. I also suspected that, just was not sure is there OLEDB provider version for desktops, and how to access it. Just foud that information in one of the mahdi posts

Dim cnx As ADODB.Connection
Set cnx = New ADODB.Connection
cnx.ConnectionString = "Provider='Microsoft.SQLSERVER.MOBILE.OLEDB.3.0.';Data Source='c:\\B.sdf';"
cnx.Open

Monday, February 13, 2012

Accessing reportviewer from web

Hi,
apologies for what I know is a very basic question. We have a very simple ASP.NET page that includes a report viewer object. The site containing the page is on a public server, and the report server is on an internal server (actually the same physical machine, but running on a different IP) - we are referencing the report server via a 10.x.x.x address and it's not connecting from outside. The report server is not accessible from the public address, and I don't believe there's firewall issues - can someone please point me in the right direction?

thanks,
Steve.

<snip>
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Security;

namespace WebReportTest2
{
/// <summary>
/// Summary description for WebForm2.
/// </summary>
public class WebForm2 : System.Web.UI.Page
{
protected System.Web.UI.HtmlControls.HtmlForm Form1;
protected System.Web.UI.WebControls.DropDownList DropDownList1;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.DropDownList Dropdownlist2;
protected System.Web.UI.HtmlControls.HtmlForm Form2;
protected System.Web.UI.WebControls.DropDownList Dropdownlist3;
protected System.Web.UI.WebControls.Button btnLogOut;
protected Microsoft.Samples.ReportingServices.ReportViewer ReportViewer1;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
//this.DropDownList1.Items.Add(new ListItem("report1,"report1"));

string param = DropDownList1.SelectedValue;
ReportViewer1.ReportPath = "/Development/report1" + param ;
ReportViewer1.ServerUrl = "http://10.72.x.x/reportserver";

}
If you log onto the console of the web server are you able to access the report server using the 10.x.x.x address? My guess would be that it is an IP/subnet issue, but I'm not really an expert in that area.|||Yep, it's actually the same server but sites running on different addresses. It looks to me like the reportviewer object is being created on the client side, and therefore can't resolve the internal 10.x.x.x address. It's not my code, and I'm no ASP.NET guru, but the object seems to be created in the ASPX page correctly, with "runat=server", but is then also created in a C# code behind page, and it's this object that's actually being created, and it's client, not server side...if all that makes sense...

cheers,
STeve.
|||

I have not done that much with the report viewer in ASP.NET, most of my experience with this control has been with the Windows Forms edition. But my understanding with the ASP.NET version was that most of the rendering takes place on the server side.

One thing thing you could checked is the permissions. If you are running the ASP.NET app from a public server I assume that you are running the standard impersonation mode which would mean that the account accessing the report server would either be the ASPNET account if you are running IIS 5 or the account that is configured for the app pool if you are running IIS 6. The account in question would need to have permission to access the report server and run the report(s) in question.

Sunday, February 12, 2012

Accessing RDL Reports from Visual Basic 6.0 Application

Hai! I don't know is this a silly question. Is it possible to execute and display the rdl (Sql server 2005 reporting services) report from visual basic 6.0 application.

I have a full fledged Visual basic windows application and using crystal reports. I want to create the reports using SQL server 2005 reporting services and access it from my Visual Basic 6.0 Windows application.

Thanks in advance

I'm afraid VB6 support has ended, and so VB6 questions are off topic here. Try www.vbcity.com instead.

Accessing publication properties from Visual Basic (VB6)

Hi all,

I have an existing application that checks a few things before it
launches another application. One thing that the application needs to
check is the subscription properties of both the local database and the
remote (LAN) server.

I've stumbled upon some properties but I am trying to fit in the last
ones and I can't seem to find the right code to accomplish this... Can
anyone shine a little light on this please ?

The following code queries the SQL Server (remote) to get (some of) the
properties of the replicated database. What I would like to fit in
after the 'state' are the properties that you can retrieve with the
EnumAllSubscriptions function. However, I can't seem to find the right
object (sample code) to retrieve those (or I'm just overlooking the
obvious)...

Here is (part of) the code I'm using to query the publication on the
remote server :

Dim oMergePublication As SQLDMO.MergePublication2
Dim oSubscription As SQLDMO.MergeSubscription2

Me.lstPublications.Clear
For Each oReplicationDatabase In
objSQLSERVER.Replication.ReplicationDatabases
If oReplicationDatabase.Name = Me.txtSQLServerDatabase.Text
Then
For Each oMergePublication In
oReplicationDatabase.MergePublications
bFoundReplicated = True
Me.lstPublications.AddItem "Database replicated as
'" & oMergePublication.Name & "'"
For Each oSubscription In
oMergePublication.MergeSubscriptions
Me.lstPublications.AddItem " - subscriber
:" & oSubscription.Subscriber
Me.lstPublications.AddItem " - local
DB :" & oSubscription.SubscriptionDB
Me.lstPublications.AddItem " -
state :" & GetReplStatus(oSubscription.Status)
Next
Next
'For Each osubscriber In oReplicationDatabase.
'Next
End If
Next
Set oReplicationDatabase = Nothing
Set oMergePublication = Nothing

After this, I also want to check the local DB (=pulled subscription)
and show some of the properties (from EnumAllSubscriptions). For
example to warn the user about the need to synchronise (last_updated
value)...

Any help appreciated,

Many thanks

GB

--
Your eyes are weary from staring at the CRT. You feel sleepy. Notice
how restful it is to watch the cursor blink. Close your eyes. The
opinions stated above are yours. When I snap my fingers, you cannot
imagine why you ever felt otherwise. <snapI'm not sure what you're asking - do you mean that you know that
EnumAllScubscriptions will return the information you need, but you
don't know how to manipulate a SQL-DMO QueryResults object? If so, then
you need to iterate over it, and use the GetColumn% methods to return
the data in the format you want - in this case, GetColumnString is
probably the best one to use.

This is a simple VBScript example of using a QueryResults object:

Option Explicit

Dim oSrv, res, c, r

Set oSrv = WScript.CreateObject("SQLDMO.SqlServer2")
oSrv.LoginSecure = True
oSrv.Name = "MyServer"
oSrv.Connect

Set res = oSrv.ExecuteWithResults("select * from sysobjects")

For r = 1 To res.Rows
For c = 1 To res.Columns
If res.ColumnName(c) = "name" Then
WScript.Echo res.GetColumnString(r, c)
End If
Next
Next

If this isn't helpful, you might get a better answer in
microsoft.public.sqlserver.replication.

Simon|||Sort of Simon,

I'm having difficulty to get the returnset from EnumAllSubscriptions in
a workable object. It just returns nothing or won't compile.
In the code I've added, I managed to get the right call for the
EnumAllSubscriptions but I'm not sure on the syntax it requires. Like :

Dim oSubscription as SQLDMO.Subscriber2
Dim oSubscriptionData as SQLDMO.<??>
For each oSubscriptiondata in
oSubscription.EnumAllSubscribers(SQLDMOSubscriptio n_All)

OR do I need to make something like
Dim Result
Dim oSubscription as SQLDMO.Subscriber2
Result = oSubscription.EnumAllSubscribers(SQLDMOSubscriptio n_All)
and then walk that Result for the correct data

Thanks anyway. I'll give this a try in the .repication group.

GB

Simon Hayes bracht volgend ide uit :
> I'm not sure what you're asking - do you mean that you know that
> EnumAllScubscriptions will return the information you need, but you
> don't know how to manipulate a SQL-DMO QueryResults object? If so, then
> you need to iterate over it, and use the GetColumn% methods to return
> the data in the format you want - in this case, GetColumnString is
> probably the best one to use.
> This is a simple VBScript example of using a QueryResults object:
> Option Explicit
> Dim oSrv, res, c, r
> Set oSrv = WScript.CreateObject("SQLDMO.SqlServer2")
> oSrv.LoginSecure = True
> oSrv.Name = "MyServer"
> oSrv.Connect
> Set res = oSrv.ExecuteWithResults("select * from sysobjects")
> For r = 1 To res.Rows
> For c = 1 To res.Columns
> If res.ColumnName(c) = "name" Then
> WScript.Echo res.GetColumnString(r, c)
> End If
> Next
> Next
>
> If this isn't helpful, you might get a better answer in
> microsoft.public.sqlserver.replication.
> Simon

--
Your eyes are weary from staring at the CRT. You feel sleepy. Notice
how restful it is to watch the cursor blink. Close your eyes. The
opinions stated above are yours. When I snap my fingers, you cannot
imagine why you ever felt otherwise. <snap