Showing posts with label sql2005. Show all posts
Showing posts with label sql2005. Show all posts

Sunday, February 19, 2012

Connection and /share file and printer/ option in Windows firewall

Hello
Is there any relation between SQL2005 connection and /share file and
printer/ option in Windows firewall?
When I check the option I can connect from remote client via script, while
not that when I unchecked the option.
I can't easily believe the two entities are related. I checked over and over
again...
If my script matters,
set con=createobject("adodb.connection")
login3="provider=SQLOLEDB; server=w3a; Initial Catalog=air;
Trusted_connection=yes; "
con.open login3
msgbox con.stateOn Dec 26 2006, 2:18 pm, "Han" <hp4...@.kornet.net.korea> wrote:
> Hello
> Is there any relation between SQL2005 connection and /share file andprinte
r/ option in Windows firewall?
> When I check the option I can connect from remote client via script, while
> not that when I unchecked the option.
> I can't easily believe the two entities are related. I checked over and ov
er
> again...
> If my script matters,
> set con=createobject("adodb.connection")
> login3="provider=SQLOLEDB; server=w3a; Initial Catalog=air;
> Trusted_connection=yes; "
> con.open login3
> msgbox con.state
I again experiencde same phenomena? Do anyone know about that?

Connection and /share file and printer/ option in Windows firewall

Hello
Is there any relation between SQL2005 connection and /share file and
printer/ option in Windows firewall?
When I check the option I can connect from remote client via script, while
not that when I unchecked the option.
I can't easily believe the two entities are related. I checked over and over
again...
If my script matters,
set con=createobject("adodb.connection")
login3="provider=SQLOLEDB; server=w3a; Initial Catalog=air;
Trusted_connection=yes; "
con.open login3
msgbox con.state
On Dec 26 2006, 2:18 pm, "Han" <hp4...@.kornet.net.korea> wrote:
> Hello
> Is there any relation between SQL2005 connection and /share file andprinter/ option in Windows firewall?
> When I check the option I can connect from remote client via script, while
> not that when I unchecked the option.
> I can't easily believe the two entities are related. I checked over and over
> again...
> If my script matters,
> set con=createobject("adodb.connection")
> login3="provider=SQLOLEDB; server=w3a; Initial Catalog=air;
> Trusted_connection=yes; "
> con.open login3
> msgbox con.state
I again experiencde same phenomena? Do anyone know about that?

Tuesday, February 14, 2012

Connecting to sql2005 using C#

Help... I am new to C# and .net and I am trying to build a insert page with a couple of drop down controls where I pull a categoryID and subcategoryID to populate my dropdown controls from a MS sql2005 express database. I am using a book that only shows how to build the script and access a access database and I am getting this error when trying to pull up the page:

Description:An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message:CS0246: The type or namespace name 'OleDbConnection' could not be found (are you missing a using directive or an assembly reference?)

Source Error:

Line 3: Line 4: <script runat="server" language="C#">Line 5: OleDbConnection objConn = newOleDbConnection(Line 6: "Server=SIMBA\\NETSDK;" +Line 7: "Database=btuniverse;" +


Source File: c:\Inetpub\wwwroot\_addnews.aspx Line: 5

Below is my code and I am not sure what the syntax needs to be when connecting to a ms sql datasource. Thanks in advanced :)

MYCODE:

<%@. Page Language="C#" MasterPageFile="~/main.master" Title="Untitled Page" %>


<script runat="server" language="C#">
OleDbConnection objConn = newOleDbConnection(
"Server=SIMBA\\NETSDK;" +
"Database=btuniverse;" +
"User ID=sa;Password=password");
OleDbCommand objCmd;
OleDbDataReader objRdr;

void Page_Load() {
if (!IsPostBack) {
objConn.Open();

objCmd = new OleDbCommand("SELECT * FROM dbo.tblNewsCategories", objConn);
objRdr = objCmd.ExecuteReader();
ddlCategory.DataSource = objRdr;
ddlCategory.DataValueField = "CategoryID";
ddlCategory.DataTextField = "CategoryName";
ddlCategory.DataBind();
objRdr.Close();

objCmd = new OleDbCommand("SELECT * FROM dbo.tblSubCategories", objConn);
objRdr = objCmd.Executereader();
ddlSubCategory.DataSource = objRdr;
ddlSubCategory.DataValueField = "SubCategoryID";
ddlSubCategory.DataTextField = "SubCategoryName";
ddlSubCategory.DataBind();
objRdr.Close();

objConn.Close();
}
}


</script>


<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<table>
<tr>
<td align="right">Title:</td>
<td align="left"><asp:TextBox ID="txtArticleTitle" CssClass="textbox" runat="server" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="txtArticleTitle" ErrorMessage="*" runat="server" />
<br />
</td>

<!-- <asp:CompareValidator ID="cvArticleTitle" ControlToValidate="txtArticleTitle" Operator="DataTypeCheck" Type="String" ErrorMessage="No numbers allowed" />-->
</tr>
<tr>
<td align="right"><p>Article Category:</td><td align="left"><asp:DropDownList ID="ddlCategory" CssClass="dropdownmenu" runat="server" /></td>
</tr>
<tr>
<td align="right"><p>Article Sub Category:</td><td align="left"><asp:DropDownList ID="ddlSubCategory" runat="server" /></td>
</tr>
<tr><td align="right">News Article:</td><td align="left"><asp:TextBox ID="txtArticleDesc" CssClass="textbox" Columns="40" Rows="4" TextMode="MultiLine" runat="server" />
<asp:RequiredFieldValidator ID="rfvArticleDesc" ControlToValidate="txtArticleDesc" ErrorMessage="*" runat="server" />
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>

<asp:Button ID="btnSubmit" CssClass="button" runat="server" Text="Submit" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
</asp:Content>

Use SQLDBConnection.
Why dont you check out the tutorials on these forums. They have good explanation with sample code too.|||thank you.

Now that I am able to query certail tables and create drop down menus i am getting an error when trying to insert my record:

Exception Details:System.Data.OleDb.OleDbException: Must declare the scalar variable "@.NewsID".

Source Error:

Line 50: objCmd.Parameters.Add("@.ArticleLink", txtArticleLink.Text);
Line 51: objConn.Open();
Line 52: objCmd.ExecuteNonQuery();
Line 53: objConn.Close();
Line 54: Response.Redirect("mynews.aspx");

HERE IS M CODE:
void SubmitNewsArticle(Object s, EventArgs e)
{
objCmd = new System.Data.OleDb.OleDbCommand(
"INSERT INTO tblNews (NewsID, ArticleDate, Title, " +
"CategoryID, SubCategoryID, ArticleDesc, ArticleLink) " +
"VALUES (@.NewsID, @.Title, @.CategoryID, " +
"@.SubCategoryID, @.ArticleDesc, @.ArticleLink)", objConn);
objCmd.Parameters.Add("@.NewsID", 1);
objCmd.Parameters.Add("@.ArticleDate", txtArticleDate.Text);
objCmd.Parameters.Add("@.Title", txtArticleTitle.Text);
objCmd.Parameters.Add("@.CategoryID",
ddlCategory.SelectedItem.Value);
objCmd.Parameters.Add("@.SubCategoryID",
ddlSubCategory.SelectedItem.Value);
objCmd.Parameters.Add("@.ArticleDesc", txtArticleDesc.Text);
objCmd.Parameters.Add("@.ArticleLink", txtArticleLink.Text);
objConn.Open();
objCmd.ExecuteNonQuery();
objConn.Close();
Response.Redirect("mynews.aspx");
}

what am I missing?? sorry for the posts :( so new to C# and .net -- I am a coldfusion web developer (1 year exp)

thanks again in advanced|||looks like you are still using OLEDB connection. What is your backend? SQL Server or Access/something else? Check ifthis articlehelps (its in VB.NET but you could get an idea of how to declare parameters and set the values).

Connecting to SQL2005 from VS2005 RC

Hi all,
Have been using SqlDataSources for a while now. Reinstalled machine last
w, now running Server 2003. Installed both SqlServer 2000 and 2005 with
instance-names "sql2000" and "sql2005". Also installed both Visual Studio
2003 and 2005. VS2005 is the Release Candidate, and SQL2005 is the September
CTP.
During SqlDataSource configuration wizard, i can test connection and all is
fine. I can see table names and views in the "query builder" thingie, but
once i do the "Test Query" things go bad. I get an "Invalid Object Name" on
the table from which the datasource should retrieve its data.
I have posted small video of me producing the error. Any input is welcomed.
I suspect the side-by-side 2000 and 2005 installation, but it _shouldn't_ be
a problem, should it?
The video is here: http://www.netkoder.dk/error.wmv
The projekt can be downloaded as a .zip from http://www.netkoder.dk/test.zip
Again, thanks for any input.
J.Jespersen
DenmarkJ,
Shot in the dark...try qualifying the table using the database.owner.object
notation.
HTH
Jerry
"J. Jespersen" <jdj@.jdj.dk> wrote in message
news:%23UMXcfdzFHA.736@.tk2msftngp13.phx.gbl...
> Hi all,
> Have been using SqlDataSources for a while now. Reinstalled machine last
> w, now running Server 2003. Installed both SqlServer 2000 and 2005 with
> instance-names "sql2000" and "sql2005". Also installed both Visual Studio
> 2003 and 2005. VS2005 is the Release Candidate, and SQL2005 is the
> September CTP.
> During SqlDataSource configuration wizard, i can test connection and all
> is fine. I can see table names and views in the "query builder" thingie,
> but once i do the "Test Query" things go bad. I get an "Invalid Object
> Name" on the table from which the datasource should retrieve its data.
> I have posted small video of me producing the error. Any input is
> welcomed. I suspect the side-by-side 2000 and 2005 installation, but it
> _shouldn't_ be a problem, should it?
> The video is here: http://www.netkoder.dk/error.wmv
> The projekt can be downloaded as a .zip from
> http://www.netkoder.dk/test.zip
> Again, thanks for any input.
> J.Jespersen
> Denmark
>
>|||
> Shot in the dark...try qualifying the table using the
> database.owner.object
> notation.
Right on target. That solved it. But....
Why do I need to fully qualify the table name? Is this an option that can be
disabled, and why doesn't the config-wizard figure this out automatically? I
really like the whole config-wizard with all the parameterizing and stuff,
but if selected table names along the way are invalid, what good is it all?
Thanks,
J.Jespersen

> Jerry
> "J. Jespersen" <jdj@.jdj.dk> wrote in message
> news:%23UMXcfdzFHA.736@.tk2msftngp13.phx.gbl...
>|||J,
Not sure I have not used that tool before. The database owner (DBO) should
really own all objects and in that context the object owner would probably
not need to be qualified - would default to DBO.
HTH
Jerry
"J. Jespersen" <jdj@.jdj.dk> wrote in message
news:eosP7GezFHA.908@.tk2msftngp13.phx.gbl...
>
> Right on target. That solved it. But....
> Why do I need to fully qualify the table name? Is this an option that can
> be disabled, and why doesn't the config-wizard figure this out
> automatically? I really like the whole config-wizard with all the
> parameterizing and stuff, but if selected table names along the way are
> invalid, what good is it all?
> Thanks,
> J.Jespersen
>
>
>
>
>
>|||"J. Jespersen" <jdj@.jdj.dk> wrote in message
news:eosP7GezFHA.908@.tk2msftngp13.phx.gbl...
>
> Right on target. That solved it. But....
> Why do I need to fully qualify the table name?
Because Contact isn't in the default schema for the connection (which is
DBO). Contact is actually in the Person schema, so it must be refered to as
Person.Schema. The Wizard is just not schema-aware. You should qualify the
table name with a schema, but not a database name.

>Is this an option that can be disabled, and why doesn't the config-wizard
>figure this out automatically?
Wizards, despite their name, really aren't actually very smart.

>I really like the whole config-wizard with all the parameterizing and
>stuff, but if selected table names along the way are invalid, what good is
>it all?
>
AdventureWorks agressively factors objects into different schemas
HumanResourses, Person, Production, etc. It does this to demonstrate that
schemas are seperated from users in Sql Server 2005, and to show one way to
use this seperation. The downside to this is that in a database like this
you need to schema-qualify most object names. For your own database you can
either put all the objects in the user's default schema, or create synonyms
in the user's default schema referring to the objects in the other schemas.
If you issue the following
create synonym dbo.Contact for Person.Contact
Your query will succeed, and you can refer to the Contact table without a
schema qualification.
David|||
> Because Contact isn't in the default schema for the connection (which is
> DBO). Contact is actually in the Person schema, so it must be refered to
> as Person.Schema. The Wizard is just not schema-aware. You should
> qualify the table name with a schema, but not a database name.
Thank you! I'll have to read up on this whole Schema thing in SQL Server.
J.Jespersen|||>Wizards, despite their name, really aren't actually very smart.
Got a kick out that!!! :-)
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
message news:%233SCieezFHA.2132@.TK2MSFTNGP15.phx.gbl...
> "J. Jespersen" <jdj@.jdj.dk> wrote in message
> news:eosP7GezFHA.908@.tk2msftngp13.phx.gbl...
> Because Contact isn't in the default schema for the connection (which is
> DBO). Contact is actually in the Person schema, so it must be refered to
> as Person.Schema. The Wizard is just not schema-aware. You should
> qualify the table name with a schema, but not a database name.
>
> Wizards, despite their name, really aren't actually very smart.
>
> AdventureWorks agressively factors objects into different schemas
> HumanResourses, Person, Production, etc. It does this to demonstrate that
> schemas are seperated from users in Sql Server 2005, and to show one way
> to use this seperation. The downside to this is that in a database like
> this you need to schema-qualify most object names. For your own database
> you can either put all the objects in the user's default schema, or create
> synonyms in the user's default schema referring to the objects in the
> other schemas. If you issue the following
> create synonym dbo.Contact for Person.Contact
> Your query will succeed, and you can refer to the Contact table without a
> schema qualification.
> David
>|||> Thank you! I'll have to read up on this whole Schema thing in SQL Server.
In SQL Server 2005 Books Online, take a look at these topics as a starting
point:
User-Schema Separation
Schemas in AdventureWorks
CREATE SCHEMA
--
Gail Erickson [MS]
SQL Server Documentation Team
This posting is provided "AS IS" with no warranties, and confers no rights
"J. Jespersen" <jdj@.jdj.dk> wrote in message
news:OpIFihezFHA.1032@.TK2MSFTNGP12.phx.gbl...
>
> Thank you! I'll have to read up on this whole Schema thing in SQL Server.
> J.Jespersen
>
>

Connecting to SQL2005 express

Hi,
I'm trying to connect to (Northwind) SQL2005 express from VS2005 express
edition .
When I test the connection, I get the error:
"Generating user instances of SQL server is disabled. Use sp_configure 'User
instances enabled' to generate user instances".
I run sp_configure with the above command, but the issue remains.
Any ideas on this?
Many thanks in advance for any help
AntDoes this help?
http://blog.devstone.com/aaron/arch...01/09/1425.aspx
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Ant" <Ant@.discussions.microsoft.com> wrote in message
news:AD271F4A-E4F8-457C-98B5-7443C6910D42@.microsoft.com...
> Hi,
> I'm trying to connect to (Northwind) SQL2005 express from VS2005 express
> edition .
> When I test the connection, I get the error:
> "Generating user instances of SQL server is disabled. Use sp_configure
> 'User
> instances enabled' to generate user instances".
> I run sp_configure with the above command, but the issue remains.
> Any ideas on this?
> Many thanks in advance for any help
> Ant

Connecting to SQL2005 express

Hi,
I'm trying to connect to (Northwind) SQL2005 express from VS2005 express
edition .
When I test the connection, I get the error:
"Generating user instances of SQL server is disabled. Use sp_configure 'User
instances enabled' to generate user instances".
I run sp_configure with the above command, but the issue remains.
Any ideas on this?
Many thanks in advance for any help
Ant
Does this help?
http://blog.devstone.com/aaron/archive/2006/01/09/1425.aspx
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Ant" <Ant@.discussions.microsoft.com> wrote in message
news:AD271F4A-E4F8-457C-98B5-7443C6910D42@.microsoft.com...
> Hi,
> I'm trying to connect to (Northwind) SQL2005 express from VS2005 express
> edition .
> When I test the connection, I get the error:
> "Generating user instances of SQL server is disabled. Use sp_configure
> 'User
> instances enabled' to generate user instances".
> I run sp_configure with the above command, but the issue remains.
> Any ideas on this?
> Many thanks in advance for any help
> Ant

Connecting to SQL2005 express

Hi,
I'm trying to connect to (Northwind) SQL2005 express from VS2005 express
edition .
When I test the connection, I get the error:
"Generating user instances of SQL server is disabled. Use sp_configure 'User
instances enabled' to generate user instances".
I run sp_configure with the above command, but the issue remains.
Any ideas on this?
Many thanks in advance for any help
AntDoes this help?
http://blog.devstone.com/aaron/archive/2006/01/09/1425.aspx
--
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Ant" <Ant@.discussions.microsoft.com> wrote in message
news:AD271F4A-E4F8-457C-98B5-7443C6910D42@.microsoft.com...
> Hi,
> I'm trying to connect to (Northwind) SQL2005 express from VS2005 express
> edition .
> When I test the connection, I get the error:
> "Generating user instances of SQL server is disabled. Use sp_configure
> 'User
> instances enabled' to generate user instances".
> I run sp_configure with the above command, but the issue remains.
> Any ideas on this?
> Many thanks in advance for any help
> Ant

Connecting to SQL2005 Developer edition

I'm attempting to connect to and instance of SQL and cannot seam to find it. The server logs says its listening on '127.0.0.1 <ipx4> 1545'.

Kind of stuck what to check next. Will using pipes help? What do I need to do?

Hi,

check if the port listening or not using command prompt as:

netstat -an | find "YOUR PORT NUMBER"

for exampl, my SQL Server is listening to port 1433:

netstat -an | find "1433"

if it's working you'll find that the port is listening to local machine in TCP otherwise maybe there is a problem, you can check the Event Viewer to trace it