Showing posts with label dim. Show all posts
Showing posts with label dim. Show all posts

Tuesday, March 27, 2012

AddParameter to SubReport ? <VbScript>

Hello,

Can i pass parameter to a subreport inside a report with addParameter ?
Like that:

Dim webSource0
Set webSource0 = CreateObject("WebReportSource.WebReportSource")
webSource0.ReportSource = webBroker
webSource0.URL = "http://localhost/product.rpt"
webSource0.PromptOnRefresh = True
webSource0.AddParameter "password0", "cria"
webSource0.AddParameter "user0", "sa"
webSource0.AddParameter "prompt0", "1"
webSource0.AddParameter "subreport.password0", "cria" ?
webSource0.AddParameter "subreport.user0", "sa" ?

when i try to view the report with crystal viewer, it prompts for the
database settings of the subreport !

i'm using cr8.5 with oledb connection and vbscriptsee thread http://www.dev-archive.com/forum/showthread.php?t=315611

I think you have the same problem, caused by not understanding that each subreport's query must establish its own permissions with the server.

Dave

Thursday, February 16, 2012

Adding data to database

would like to enquiry about the following codes to adding data to the database, it does not work.

Dim sqlConn As New SqlClient.SqlConnection
Dim sqlCmd1 As New SqlClient.SqlCommand
Dim sqlCmd2 As New SqlClient.SqlCommand
Dim insertCmd As New SqlClient.SqlCommand
Dim sdrData As SqlClient.SqlDataReader

sqlConn.ConnectionString = "server=localhost;database=Tsign;uid=sa;pwd=;"
sqlConn.Open()
sqlCmd1.CommandText = "select * from Customer where userId='" + userId.Text + "'"
sqlCmd1.Connection = sqlConn
sqlCmd2.CommandText = "select * from Customer where email='" + email.Text + "'"
sqlCmd2.Connection = sqlConn
sdrData = sqlCmd1.ExecuteReader()
If sdrData.Read() Then
userNameTaken.Visible = True
Else
sdrData = sqlCmd2.ExecuteReader()
If sdrData.Read() Then
userEmailTaken.Visible = True
Else
insertCmd.CommandText = "INSERT INTO Customer(name, address, gender, password, occupation, income, m_status, email, hPhone, oPhone, dob, tPhone, userId) VALUES('" + userId.Text + "', '" + password.Text + "', '" + email.Text + "', '" + nameCust.Text + "', '" + dob.Text + "', '" + gender.SelectedValue + "', '" + address.Text + "', '" + occupation.Text + "', '" + income.SelectedValue + "', '" + m_status.SelectedValue + "', " + hPhone.Text + ", " + oPhone.Text + ", " + tPhone.Text + ")"
insertCmd.Connection = sqlConn
sdrData = insertCmd.ExecuteNonQuery()
Dim name As String = sdrData("name")
Session("userid") = name
Response.Redirect("welcome.aspx")
End If
End If
sqlConn.Close()1. do you get any errors?
2. do you know that the 'insert' condition is being fired?|||One thought (the best one can do without any information aboutexactly what the problem is) is that you should surround [password] and [name] in square brackets, as they are reserved words.

Also, are hPhone and oPhone strings? If so, the insert statement needs single quotes around those values.|||douglas, that's more perceptive than me, and I wish I'd spotted it. then again, it's friday. have one on me.|||when i tried to browse the page in Visual studio, it popups a window with a warning, but i can preview the page anyway. and when i fill in the details and click submit, all the page does is refresh itself.

Sunday, February 12, 2012

Adding an sql table through VS2005

Hi,

Currently I am able to check for and add a column to an SQL database using this:

Dim connectionstring As String = My.Settings.ConnectionString

Dim eSQL As String = ""

Using connection As New System.Data.SqlClient.SqlConnection(connectionstring)

Dim cmd As New System.Data.SqlClient.SqlCommand(eSQL, connection)

connection.Open()

eSQL = "IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'dbo' AND TABLE_NAME = 'Client' AND COLUMN_NAME = 'Company' ) " _

& "BEGIN " _

& "ALTER TABLE [Client] " _

& "ADD Company int " _

& "END "

cmd.CommandText = eSQL

cmd.ExecuteNonQuery()

End Using

I would now like to add a completely new table with two columns to the same database. What syntax would I use?

hi,

GraemeP wrote:

Hi,

I would now like to add a completely new table with two columns to the same database. What syntax would I use?

eSQL = "IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'dbo' AND TABLE_NAME = 'Client' AND TABLE_TYPE = 'BASE TABLE' ) " _

& "BEGIN " _

& "CREATE TABLE [Client] (" _

& "Company int NOT NULL PRIMARY KEY," _

& "Name varchar(100) NOT NULL DEFAULT 'new company');" _

& "END;"

regards

|||Perfect - thanks!|||

Hi,

I'm getting on fine adding tables and fields programmatically to an SQL database, however I now want to add a view in the same way.

Is this possible, if so would appreciate some sample code.

|||

hi,

GraemeP wrote:

Hi,

I'm getting on fine adding tables and fields programmatically to an SQL database, however I now want to add a view in the same way.

Is this possible, if so would appreciate some sample code.

the very same pattern is not possible for views, as the CREATE VIE statement must be the first in it's own batch... typically you'll overcome this problem dropping the view, if existing like

SET NOCOUNT ON; USE tempdb; GO CREATE VIEW dbo.v1 AS SELECT 1 AS [ColX]; GO IF OBJECT_ID('dbo.v1') IS NOT NULL BEGIN PRINT 'drop'; DROP VIEW dbo.v1; END; GO CREATE VIEW dbo.v1 AS SELECT 1 AS [ColX]; GO DROP VIEW dbo.v1;

but this method has gotchas.. all permissions eventually set are gone when the objec is dropped..

regards