Sunday, February 12, 2012

Connecting to SQL Server,,,Error Server Does not exist or access denied

Hello

please assist me I will appreciate it

I have a problem in my scripting I gues,I "ve done the config and server registrations and allow a public permission ,but stil giving me trouble

well this is my coding:::::::
<

<script language="vb" runat="server"
Dim MyConnection As SqlConnection

Sub Page_Load(Sender As Object, E As EventArgs)

MyConnection = New SqlConnection("server=(localHost);Database=CampusLANDB;Trusted_Connection=yes")

If Not (IsPostBack)

Dim DS As DataSet

Dim MyCommand As SqlDataAdapter

MyCommand = New SqlDataAdapter("Select distinct State from Authors",MyConnection)

DS=New DataSet()

MyCommand.Fill(DS,"tStudents") ' This is where the pro underlies

MySelect.DataSource=DS.Tables("Name").DefaultView
MySelect.DataBind()
End if
End Sub

sub GetName_Click(Sender As Object,E As EventArgs)

Dim SelectCmd As String = "Select From tStudents Where Name =@.Name "

Dim DS As DataSet
Dim MyCommand As SqlDataAdapter

MyCommand = new sqldataAdapter(SelectCmd, MyConnection)

MyCommand.SelectCommand.Parameters.Add(New SqlParameter("@.Name",SqlDbType.VarChar,2))
MyCommand.SelectCommand.Parameters("@.Name").Value = MySelect.Value

DS= new DataSet()
MyCommand.Fill(DS,"tStudents")

MyDataGrid.DataSource=DS.Tables("tStudents").DefaultView
MyDataGrid.DataBind()
End sub

</script
and I will apreciate if anyone vcan help me urgently

PPMFor this to work, you must make the ASPNET Windows user a user in SQL Server, and give that user rights to the database in question.|||can you run any queries in the QA ?|||Your connection string is incorrrect. Use on of the following syntax (preferably the first one):

server=(local); Database=CampusLANDB; Trusted_Connection=yes
server=localhost; Database=CampusLANDB; Trusted_Connection=yes
server=MACHINE_NAME; Database=CampusLANDB; Trusted_Connection=yes
server=IP.ADD.RE.SS; Database=CampusLANDB; Trusted_Connection=yes (not really sure)

Regards

No comments:

Post a Comment