Showing posts with label object. Show all posts
Showing posts with label object. Show all posts

Tuesday, March 27, 2012

Adding a loggin to a server

In DMO the server object had an add method on the Logins collection. Does anyone know how this works in SMO the logins collection does not have an add.

I have spent hours on this and just cannot figure out how to create a new login on a server using SMO. I guess I could allways script the login but there must ba a way to do this in SMO.

Thanks

You can create a login as follows:

Server srv = new Server("MyServer"); //Yukon

srv.ConnectionContext.LoginSecure = true;

srv.ConnectionContext.Connect();

srv.DefaultTextMode = false;

string lgName = "MyNewLogin";

if (srv.Logins[lgName] == null)

{

Login lg = new Login(srv, lgName);

lg.LoginType = LoginType.SqlLogin;

lg.Create("MyPassword!#");

}

Peter

Thursday, March 8, 2012

Add New Row Problems

This code runs with no errors.
The problem is nothing actually gets updated.

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim mEmp As New YessClass1
Dim EmpID As Long
Dim Conn As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))

'Dim mRdg As YessClass1 = New YessClass1
Dim lngID As Long
'This is to save a record to tblFeedback
Dim strSelect As String = "SELECT * FROM tblFeedback"
'now create the data adapter object and connect it to
'sql string and the connection
Dim dscmd As New SqlDataAdapter(strSelect, Conn)
' Load a data set.
ds = New DataSet
'data Adapter fill with dataset, name of dataset
dscmd.Fill(ds, "Feedback")
SqlConnection1.Close()
'get the EmployeeID and the Rounding RecordID
Try
mEmp = CType(Session("objEmp"), YessClass1)
EmpID = mEmp.Employee
Try
Dim dt As DataTable = ds.Tables.Item("FeedBack")
Dim rowFeedback As DataRow = dt.NewRow

With rowFeedback
.Item("RoundingID") = RdgID
.Item("QuestionID") = Me.lstQuestion.SelectedItem.Value
.Item("ResponseActionID") = Me.lstAction.SelectedItem.Value
.Item("EmployeeID") = Me.lstDirector.SelectedItem.Value
.Item("ActivityID") = Me.lstActivity.SelectedItem.Value
.Item("Feedback") = Me.txtFeedback.Text
If Me.ckReq.Checked = True Then
.Item("Acknowledgement") = 1
.Item("AckDate") = Now
End If
End With

dt.Rows.Add(rowFeedback)

Catch ex As Exception

Response.Write("Error occured" & ex.Message)
End Try
Catch ex As Exception
Response.Write("ERROR: " & ex.Message)
End Try
End SubWhere are you actually updating the database? Adding the row to the DataTable does not do it. You need to call .Update somewhere on the DataSet.

Sunday, February 19, 2012

add an image to the web page

hi

u didnot get the question!

I asked I copeid an image to the app_data folder and dropdowned a image object to the web form, image--> style-->background-->background image-->select back ground image from the app_data folder , the image appear on the page but when I debug the page it donot display

Thats because you posted in the wrong forum, this is a SQL Server Express forum and depending on the rare information you gave, I assumed that you want to load the image from SQL Server and display it in a webpage. If the file is on disk you will have to provide the code you are using to do this. BTW the app_data folder is reserved for storing data not the actual res / misc files.

Jens K. Suessmeyer.

http://www.sqlserver2005.de